Decompiled source of Cartographer Minimap v1.0.0

plugins/Cartographer_Minimap/Cartographer.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Cartographer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Cartographer")]
[assembly: AssemblyTitle("Cartographer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 Cartographer
{
	[BepInPlugin("com.cartographer.minimap", "Cartographer Minimap", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class CartographerPlugin : BaseUnityPlugin
	{
		public const string PluginName = "Cartographer Minimap";

		public const string PluginGUID = "com.cartographer.minimap";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		private GameObject runner;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			MinimapConfig.Init(((BaseUnityPlugin)this).Config);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat.Init();
			}
			runner = new GameObject("Cartographer");
			Object.DontDestroyOnLoad((Object)(object)runner);
			runner.AddComponent<MinimapController>();
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)runner))
			{
				Object.Destroy((Object)(object)runner);
			}
		}
	}
	internal static class GameIcons
	{
		private const string Inspect = "RoR2/Base/";

		private const string Misc = "RoR2/Base/Common/MiscIcons/";

		private static readonly Dictionary<Category, string> keys = new Dictionary<Category, string>
		{
			{
				Category.Teleporter,
				"RoR2/Base/Common/MiscIcons/texTeleporterIconOutlined.png"
			},
			{
				Category.Portal,
				"RoR2/Base/RadioScannerIcon_2.png"
			},
			{
				Category.SmallChest,
				"RoR2/Base/ChestIcon_1.png"
			},
			{
				Category.LargeChest,
				"RoR2/Base/ChestIcon_1.png"
			},
			{
				Category.LegendaryChest,
				"RoR2/Base/ChestIcon_1.png"
			},
			{
				Category.CategoryChest,
				"RoR2/Base/ChestIcon_1.png"
			},
			{
				Category.EquipmentBarrel,
				"RoR2/Base/ChestIcon_1.png"
			},
			{
				Category.LunarPod,
				"RoR2/Base/PillarIcon.png"
			},
			{
				Category.VoidChest,
				"RoR2/Base/VoidIcon_2.png"
			},
			{
				Category.Shop,
				"RoR2/Base/Common/MiscIcons/texInventoryIconOutlined.png"
			},
			{
				Category.Printer,
				"RoR2/Base/PrinterIcon_1.png"
			},
			{
				Category.Scrapper,
				"RoR2/Base/ScrapperIcon.png"
			},
			{
				Category.Cauldron,
				"RoR2/Base/Common/MiscIcons/texMysteryIcon.png"
			},
			{
				Category.Shrine,
				"RoR2/Base/ShrineIcon.png"
			},
			{
				Category.NewtAltar,
				"RoR2/Base/LunarIcon_1.png"
			},
			{
				Category.Drone,
				"RoR2/Base/Common/MiscIcons/texDroneIconOutlined.png"
			},
			{
				Category.Barrel,
				"RoR2/Base/Common/MiscIcons/texBarrelIcon.png"
			},
			{
				Category.Item,
				"RoR2/Base/Common/MiscIcons/texLootIconOutlined.png"
			},
			{
				Category.Other,
				"RoR2/Base/Common/MiscIcons/texMysteryIcon.png"
			},
			{
				Category.Boss,
				"RoR2/Base/Common/MiscIcons/texAttackIcon.png"
			}
		};

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

		public static void Preload()
		{
			foreach (Category key in keys.Keys)
			{
				Get(key);
			}
		}

		public static Sprite Get(Category category)
		{
			if (!keys.TryGetValue(category, out var value))
			{
				return null;
			}
			if (cache.TryGetValue(value, out var value2))
			{
				return value2;
			}
			value2 = Load(value);
			cache[value] = value2;
			return value2;
		}

		private static Sprite Load(string key)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			try
			{
				Sprite val = Addressables.LoadAssetAsync<Sprite>((object)key).WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			catch (Exception)
			{
			}
			try
			{
				Texture2D val2 = Addressables.LoadAssetAsync<Texture2D>((object)key).WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val2))
				{
					return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
				}
			}
			catch (Exception ex2)
			{
				CartographerPlugin.Log.LogWarning((object)("Couldn't load icon '" + key + "', using a shape instead: " + ex2.Message));
			}
			return null;
		}
	}
	internal static class IconSprites
	{
		private const int IconResolution = 64;

		private const int MaskResolution = 256;

		private static readonly Dictionary<IconShape, Sprite> icons = new Dictionary<IconShape, Sprite>();

		private static Sprite circleMask;

		private static Sprite squareMask;

		private static Sprite arrow;

		public static Sprite Icon(IconShape shape)
		{
			if (!icons.TryGetValue(shape, out var value) || !Object.op_Implicit((Object)(object)value))
			{
				value = Bake(64, 0.18f, (Vector2 p) => Sdf(shape, p));
				icons[shape] = value;
			}
			return value;
		}

		public static Sprite Mask(MapShape shape)
		{
			if (shape == MapShape.Circle)
			{
				if (!Object.op_Implicit((Object)(object)circleMask))
				{
					circleMask = Bake(256, 0f, (Vector2 p) => ((Vector2)(ref p)).magnitude - 1f);
				}
				return circleMask;
			}
			if (!Object.op_Implicit((Object)(object)squareMask))
			{
				squareMask = Bake(8, 0f, (Vector2 p) => -1f);
			}
			return squareMask;
		}

		public static Sprite Arrow()
		{
			if (!Object.op_Implicit((Object)(object)arrow))
			{
				arrow = Bake(64, 0.14f, (Vector2 p) => Polygon(p, new Vector2(0f, 0.95f), new Vector2(-0.7f, -0.75f), new Vector2(0f, -0.4f), new Vector2(0.7f, -0.75f)));
			}
			return arrow;
		}

		private static float Sdf(IconShape shape, Vector2 p)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c7: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			return shape switch
			{
				IconShape.Square => Box(p, new Vector2(0.75f, 0.75f)), 
				IconShape.Diamond => (Mathf.Abs(p.x) + Mathf.Abs(p.y) - 0.9f) * 0.7071f, 
				IconShape.Triangle => Polygon(p, new Vector2(0f, 0.85f), new Vector2(-0.8f, -0.7f), new Vector2(0.8f, -0.7f)), 
				IconShape.Ring => Mathf.Abs(((Vector2)(ref p)).magnitude - 0.62f) - 0.2f, 
				IconShape.Star => Star(p, 0.9f, 0.45f), 
				IconShape.Cross => Mathf.Min(Box(p, new Vector2(0.8f, 0.26f)), Box(p, new Vector2(0.26f, 0.8f))), 
				_ => ((Vector2)(ref p)).magnitude - 0.8f, 
			};
		}

		private static Sprite Bake(int size, float outline, Func<Vector2, float> sdf)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0087: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			Color32[] array = (Color32[])(object)new Color32[size * size];
			float num = 1f + outline;
			float num2 = 2f / (float)size * num;
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					Vector2 arg = new Vector2(((float)j + 0.5f) / (float)size * 2f - 1f, ((float)i + 0.5f) / (float)size * 2f - 1f) * num;
					float num3 = sdf(arg);
					float num4 = Mathf.Clamp01(0.5f - num3 / num2);
					float num5 = ((outline > 0f) ? Mathf.Clamp01(0.5f - (num3 - outline) / num2) : 0f);
					float num6 = Mathf.Max(num4, num5 * 0.9f);
					byte b = (byte)(Mathf.Clamp01((num6 > 0f) ? (num4 / Mathf.Max(num6, 0.0001f)) : 0f) * 255f);
					array[i * size + j] = new Color32(b, b, b, (byte)(num6 * 255f));
				}
			}
			val.SetPixels32(array);
			val.Apply(false, true);
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
			((Object)obj).hideFlags = (HideFlags)61;
			return obj;
		}

		private static float Box(Vector2 p, Vector2 b)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003e: 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)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(Mathf.Abs(p.x) - b.x, Mathf.Abs(p.y) - b.y);
			Vector2 val2 = Vector2.Max(val, Vector2.zero);
			return ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(val.x, val.y), 0f);
		}

		private static float Polygon(Vector2 p, params Vector2[] v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector2.Dot(p - v[0], p - v[0]);
			float num2 = 1f;
			int i = 0;
			int num3 = v.Length - 1;
			for (; i < v.Length; i++)
			{
				Vector2 val = v[num3] - v[i];
				Vector2 val2 = p - v[i];
				Vector2 val3 = val2 - val * Mathf.Clamp01(Vector2.Dot(val2, val) / Vector2.Dot(val, val));
				num = Mathf.Min(num, Vector2.Dot(val3, val3));
				bool flag = p.y >= v[i].y;
				bool flag2 = p.y < v[num3].y;
				bool flag3 = val.x * val2.y > val.y * val2.x;
				if ((flag && flag2 && flag3) || (!flag && !flag2 && !flag3))
				{
					num2 = 0f - num2;
				}
				num3 = i;
			}
			return num2 * Mathf.Sqrt(num);
		}

		private static float Star(Vector2 p, float r, float rf)
		{
			//IL_0013: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_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_005c: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0083: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.809017f, -0.58778524f);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f - val.x, val.y);
			p.x = Mathf.Abs(p.x);
			p -= 2f * Mathf.Max(Vector2.Dot(val, p), 0f) * val;
			p -= 2f * Mathf.Max(Vector2.Dot(val2, p), 0f) * val2;
			p.x = Mathf.Abs(p.x);
			p.y -= r;
			Vector2 val3 = rf * new Vector2(0f - val.y, val.x) - new Vector2(0f, 1f);
			float num = Mathf.Clamp(Vector2.Dot(p, val3) / Vector2.Dot(val3, val3), 0f, r);
			Vector2 val4 = p - val3 * num;
			return ((Vector2)(ref val4)).magnitude * Mathf.Sign(p.y * val3.x - p.x * val3.y);
		}
	}
	internal sealed class CategoryConfig
	{
		public ConfigEntry<bool> Enabled;

		public ConfigEntry<Color> Color;

		public ConfigEntry<IconShape> Shape;

		public ConfigEntry<float> Size;

		public ConfigEntry<bool> ClampToEdge;
	}
	internal static class MinimapConfig
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<KeyboardShortcut> ToggleKey;

		public static ConfigEntry<KeyboardShortcut> ExpandKey;

		public static ConfigEntry<KeyboardShortcut> ZoomInKey;

		public static ConfigEntry<KeyboardShortcut> ZoomOutKey;

		public static ConfigEntry<bool> HideUsed;

		public static ConfigEntry<MapAnchor> Anchor;

		public static ConfigEntry<float> OffsetX;

		public static ConfigEntry<float> OffsetY;

		public static ConfigEntry<float> Size;

		public static ConfigEntry<MapShape> Shape;

		public static ConfigEntry<Color> BackgroundColor;

		public static ConfigEntry<Color> BorderColor;

		public static ConfigEntry<float> BorderWidth;

		public static ConfigEntry<float> Zoom;

		public static ConfigEntry<bool> RotateWithCamera;

		public static ConfigEntry<bool> ShowNorth;

		public static ConfigEntry<IconStyle> IconStyle;

		public static ConfigEntry<float> GameIconSizeBonus;

		public static ConfigEntry<float> IconScale;

		public static ConfigEntry<float> HeightThreshold;

		public static ConfigEntry<bool> ItemsUseRarityColor;

		public static ConfigEntry<Color> PlayerArrowColor;

		public static ConfigEntry<float> PlayerArrowSize;

		public static ConfigEntry<float> ExpandedSize;

		public static ConfigEntry<float> ExpandedZoom;

		public static ConfigEntry<bool> ShowTerrain;

		public static ConfigEntry<int> TerrainResolution;

		public static ConfigEntry<int> TerrainFps;

		public static ConfigEntry<float> TerrainCeiling;

		public static ConfigEntry<float> TerrainDepth;

		public static ConfigEntry<Color> TerrainTint;

		public static readonly CategoryConfig[] Categories = new CategoryConfig[Enum.GetValues(typeof(Category)).Length];

		public const float MinZoom = 15f;

		public const float MaxZoom = 600f;

		public static void Init(ConfigFile cfg)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Expected O, but got Unknown
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Expected O, but got Unknown
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Expected O, but got Unknown
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Expected O, but got Unknown
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Expected O, but got Unknown
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Expected O, but got Unknown
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Expected O, but got Unknown
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0669: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Expected O, but got Unknown
			Enabled = cfg.Bind<bool>("1. General", "Enabled", true, "Show the minimap.");
			ToggleKey = cfg.Bind<KeyboardShortcut>("1. General", "Toggle Key", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), "Show / hide the minimap.");
			ExpandKey = cfg.Bind<KeyboardShortcut>("1. General", "Expand Key", new KeyboardShortcut((KeyCode)109, Array.Empty<KeyCode>()), "Toggle the large centered map.");
			ZoomInKey = cfg.Bind<KeyboardShortcut>("1. General", "Zoom In Key", new KeyboardShortcut((KeyCode)61, Array.Empty<KeyCode>()), "Zoom in (applies to whichever map mode is active).");
			ZoomOutKey = cfg.Bind<KeyboardShortcut>("1. General", "Zoom Out Key", new KeyboardShortcut((KeyCode)45, Array.Empty<KeyCode>()), "Zoom out (applies to whichever map mode is active).");
			HideUsed = cfg.Bind<bool>("1. General", "Hide Used Interactables", true, "Hide opened chests, used shrines, etc. If false they are shown faded instead.");
			Anchor = cfg.Bind<MapAnchor>("2. Layout", "Anchor", MapAnchor.TopLeft, "Screen corner the minimap is attached to.");
			OffsetX = cfg.Bind<float>("2. Layout", "Offset X", 20f, new ConfigDescription("Horizontal distance from the corner (HUD pixels at 1080p).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1500f), Array.Empty<object>()));
			OffsetY = cfg.Bind<float>("2. Layout", "Offset Y", 20f, new ConfigDescription("Vertical distance from the corner (HUD pixels at 1080p).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 900f), Array.Empty<object>()));
			Size = cfg.Bind<float>("2. Layout", "Size", 260f, new ConfigDescription("Minimap diameter / width in HUD pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 800f), Array.Empty<object>()));
			Shape = cfg.Bind<MapShape>("2. Layout", "Shape", MapShape.Circle, "Circle or square minimap.");
			BackgroundColor = cfg.Bind<Color>("2. Layout", "Background Color", new Color(0.05f, 0.06f, 0.08f, 0.75f), "Color behind the map.");
			BorderColor = cfg.Bind<Color>("2. Layout", "Border Color", new Color(0.8f, 0.8f, 0.8f, 0.9f), "Border color.");
			BorderWidth = cfg.Bind<float>("2. Layout", "Border Width", 3f, new ConfigDescription("Border thickness in HUD pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			Zoom = cfg.Bind<float>("3. Map", "Zoom", 70f, new ConfigDescription("Meters from the center of the minimap to its edge.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 600f), Array.Empty<object>()));
			RotateWithCamera = cfg.Bind<bool>("3. Map", "Rotate With Camera", true, "Rotate the map so the camera's forward direction is always up. If false, north is always up.");
			ShowNorth = cfg.Bind<bool>("3. Map", "Show North Marker", true, "Show an 'N' on the edge of the map pointing north.");
			IconStyle = cfg.Bind<IconStyle>("3. Map", "Icon Style", Cartographer.IconStyle.Game, "Game: use the game's own icons (chest, printer, shrine, teleporter...). Shapes: use the per-category Shape setting. Enemies, allies and players are always shapes.");
			GameIconSizeBonus = cfg.Bind<float>("3. Map", "Game Icon Size Bonus", 8f, new ConfigDescription("Extra pixels added to icon sizes when Icon Style is Game, since detailed icons need more room than plain shapes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 32f), Array.Empty<object>()));
			IconScale = cfg.Bind<float>("3. Map", "Icon Scale", 1f, new ConfigDescription("Global multiplier for every icon size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 4f), Array.Empty<object>()));
			HeightThreshold = cfg.Bind<float>("3. Map", "Height Arrow Threshold", 12f, new ConfigDescription("Show a small up/down arrow on icons that are more than this many meters above or below you. 0 disables.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 200f), Array.Empty<object>()));
			ItemsUseRarityColor = cfg.Bind<bool>("3. Map", "Items Use Rarity Color", true, "Color dropped items by their tier (white/green/red/lunar/void...) instead of the Item category color.");
			PlayerArrowColor = cfg.Bind<Color>("3. Map", "Player Arrow Color", new Color(1f, 0.9f, 0.2f), "Color of the arrow representing you.");
			PlayerArrowSize = cfg.Bind<float>("3. Map", "Player Arrow Size", 16f, new ConfigDescription("Size of the arrow representing you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 64f), Array.Empty<object>()));
			ExpandedSize = cfg.Bind<float>("4. Expanded Map", "Size", 720f, new ConfigDescription("Size of the expanded map in HUD pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(200f, 1080f), Array.Empty<object>()));
			ExpandedZoom = cfg.Bind<float>("4. Expanded Map", "Zoom", 220f, new ConfigDescription("Meters from the center of the expanded map to its edge.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 600f), Array.Empty<object>()));
			ShowTerrain = cfg.Bind<bool>("5. Terrain", "Show Terrain", true, "Render a top-down view of the level under the icons. Costs some performance; disable for icons only.");
			TerrainResolution = cfg.Bind<int>("5. Terrain", "Resolution", 256, new ConfigDescription("Render texture size of the terrain view (doubled for the expanded map).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(64, 1024), Array.Empty<object>()));
			TerrainFps = cfg.Bind<int>("5. Terrain", "Refresh Rate", 30, new ConfigDescription("How many times per second the terrain view is redrawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 144), Array.Empty<object>()));
			TerrainCeiling = cfg.Bind<float>("5. Terrain", "Ceiling Height", 25f, new ConfigDescription("Geometry more than this many meters above you is cut away, so roofs, caves and canopies don't hide the map.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 500f), Array.Empty<object>()));
			TerrainDepth = cfg.Bind<float>("5. Terrain", "Depth", 250f, new ConfigDescription("How far below you geometry is still drawn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 1000f), Array.Empty<object>()));
			TerrainTint = cfg.Bind<Color>("5. Terrain", "Tint", new Color(1f, 1f, 1f, 0.9f), "Multiplied with the terrain image. Lower alpha to make it more transparent.");
			foreach (Category value in Enum.GetValues(typeof(Category)))
			{
				CategoryDefaults categoryDefaults = CategoryDefaults.For(value);
				string text = "Icon: " + value;
				Categories[(int)value] = new CategoryConfig
				{
					Enabled = cfg.Bind<bool>(text, "Enabled", categoryDefaults.Enabled, "Show on the minimap: " + categoryDefaults.Description),
					Color = cfg.Bind<Color>(text, "Color", categoryDefaults.Color, "Icon color."),
					Shape = cfg.Bind<IconShape>(text, "Shape", categoryDefaults.Shape, "Icon shape when Icon Style is Shapes (or if this category has no game icon)."),
					Size = cfg.Bind<float>(text, "Size", categoryDefaults.Size, new ConfigDescription("Icon size in HUD pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 64f), Array.Empty<object>())),
					ClampToEdge = cfg.Bind<bool>(text, "Clamp To Edge", categoryDefaults.ClampToEdge, "Keep the icon pinned to the edge of the map when it is out of range instead of hiding it.")
				};
			}
		}

		public static CategoryConfig Get(Category category)
		{
			return Categories[(int)category];
		}
	}
	internal sealed class MinimapController : MonoBehaviour
	{
		private const float ZoomStep = 1.25f;

		private readonly ObjectTracker tracker = new ObjectTracker();

		private readonly TerrainRenderer terrain = new TerrainRenderer();

		private MinimapView view;

		private HUD viewHud;

		private bool expanded;

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!IsTyping())
			{
				if (Pressed(MinimapConfig.ToggleKey.Value))
				{
					MinimapConfig.Enabled.Value = !MinimapConfig.Enabled.Value;
				}
				if (Pressed(MinimapConfig.ExpandKey.Value) && MinimapConfig.Enabled.Value)
				{
					expanded = !expanded;
				}
				ConfigEntry<float> val = (expanded ? MinimapConfig.ExpandedZoom : MinimapConfig.Zoom);
				if (Pressed(MinimapConfig.ZoomInKey.Value))
				{
					SetZoom(val, val.Value / 1.25f);
				}
				if (Pressed(MinimapConfig.ZoomOutKey.Value))
				{
					SetZoom(val, val.Value * 1.25f);
				}
			}
		}

		private static bool Pressed(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_0029: 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;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		private void LateUpdate()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			if (!MinimapConfig.Enabled.Value || !Object.op_Implicit((Object)(object)Run.instance))
			{
				Hide();
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CameraRigController val = ((firstLocalUser != null) ? firstLocalUser.cameraRigController : null);
			HUD val2 = (Object.op_Implicit((Object)(object)val) ? val.hud : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.mainContainer) || !Object.op_Implicit((Object)(object)val.sceneCam))
			{
				Hide();
				return;
			}
			if (view == null || !view.IsAlive || (Object)(object)viewHud != (Object)(object)val2)
			{
				view?.Destroy();
				GameIcons.Preload();
				view = new MinimapView(val2.mainContainer.transform);
				viewHud = val2;
			}
			tracker.Tick();
			CharacterBody cachedBody = firstLocalUser.cachedBody;
			Vector3 center = (Object.op_Implicit((Object)(object)cachedBody) ? cachedBody.footPosition : ((!Object.op_Implicit((Object)(object)val.target)) ? ((Component)val.sceneCam).transform.position : val.target.transform.position));
			float y = ((Component)val.sceneCam).transform.eulerAngles.y;
			float yaw = (MinimapConfig.RotateWithCamera.Value ? y : 0f);
			float zoom = (expanded ? MinimapConfig.ExpandedZoom.Value : MinimapConfig.Zoom.Value);
			Texture val3 = null;
			if (MinimapConfig.ShowTerrain.Value)
			{
				int resolution = MinimapConfig.TerrainResolution.Value * ((!expanded) ? 1 : 2);
				terrain.Render(center, yaw, zoom, resolution, Time.unscaledDeltaTime);
				val3 = terrain.Texture;
			}
			view.SetVisible(visible: true);
			view.Render(center, y, cachedBody, tracker.Objects, expanded, val3);
		}

		private void Hide()
		{
			view?.SetVisible(visible: false);
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				tracker.Clear();
			}
		}

		private void OnDestroy()
		{
			view?.Destroy();
			terrain.Dispose();
		}

		private static void SetZoom(ConfigEntry<float> entry, float value)
		{
			entry.Value = Mathf.Clamp(value, 15f, 600f);
		}

		private static bool IsTyping()
		{
			if (Object.op_Implicit((Object)(object)ChatBox.instance) && ChatBox.instance.showInput)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)ConsoleWindow.instance))
			{
				return true;
			}
			GameObject val = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (!Object.op_Implicit((Object)(object)val.GetComponent<TMP_InputField>()))
				{
					return Object.op_Implicit((Object)(object)val.GetComponent<InputField>());
				}
				return true;
			}
			return false;
		}
	}
	internal sealed class MinimapView
	{
		private sealed class Icon
		{
			public GameObject GameObject;

			public RectTransform Rect;

			public Image Image;

			public RectTransform HeightRect;

			public Image HeightImage;
		}

		private sealed class IconLayer
		{
			public RectTransform Container;

			public readonly List<Icon> Pool = new List<Icon>();

			public int Used;
		}

		private static readonly Category[] DrawOrder = new Category[23]
		{
			Category.Enemy,
			Category.Ally,
			Category.Other,
			Category.Barrel,
			Category.Item,
			Category.Drone,
			Category.Shop,
			Category.SmallChest,
			Category.CategoryChest,
			Category.LargeChest,
			Category.EquipmentBarrel,
			Category.LunarPod,
			Category.VoidChest,
			Category.Scrapper,
			Category.Printer,
			Category.Cauldron,
			Category.Shrine,
			Category.NewtAltar,
			Category.LegendaryChest,
			Category.Portal,
			Category.Teleporter,
			Category.Boss,
			Category.Player
		};

		public readonly RectTransform Root;

		private readonly Image border;

		private readonly RectTransform maskRect;

		private readonly Image maskImage;

		private readonly RawImage terrainImage;

		private readonly RectTransform iconRoot;

		private readonly IconLayer[] layers = new IconLayer[Enum.GetValues(typeof(Category)).Length];

		private readonly RectTransform playerArrow;

		private readonly Image playerArrowImage;

		private readonly RectTransform northRect;

		private readonly TextMeshProUGUI northText;

		private float radius;

		private float pixelsPerMeter;

		private float rotSin;

		private float rotCos;

		private bool circular;

		public bool IsAlive => Object.op_Implicit((Object)(object)Root);

		public MinimapView(Transform parent)
		{
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			Root = NewRect("Cartographer Minimap", parent);
			((Component)Root).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			((Component)Root).gameObject.AddComponent<Canvas>();
			border = ((Component)NewRect("Border", (Transform)(object)Root)).gameObject.AddComponent<Image>();
			Stretch(((Graphic)border).rectTransform, 0f);
			((Graphic)border).raycastTarget = false;
			maskRect = NewRect("Mask", (Transform)(object)Root);
			maskImage = ((Component)maskRect).gameObject.AddComponent<Image>();
			((Graphic)maskImage).raycastTarget = false;
			((Component)maskRect).gameObject.AddComponent<Mask>().showMaskGraphic = true;
			terrainImage = ((Component)NewRect("Terrain", (Transform)(object)maskRect)).gameObject.AddComponent<RawImage>();
			Stretch(((Graphic)terrainImage).rectTransform, 0f);
			((Graphic)terrainImage).raycastTarget = false;
			iconRoot = NewRect("Icons", (Transform)(object)Root);
			Stretch(iconRoot, 0f);
			Category[] drawOrder = DrawOrder;
			for (int i = 0; i < drawOrder.Length; i++)
			{
				Category category = drawOrder[i];
				RectTransform val = NewRect(category.ToString(), (Transform)(object)iconRoot);
				Stretch(val, 0f);
				layers[(int)category] = new IconLayer
				{
					Container = val
				};
			}
			playerArrow = NewRect("Player", (Transform)(object)Root);
			playerArrowImage = ((Component)playerArrow).gameObject.AddComponent<Image>();
			playerArrowImage.sprite = IconSprites.Arrow();
			((Graphic)playerArrowImage).raycastTarget = false;
			northRect = NewRect("North", (Transform)(object)Root);
			northRect.sizeDelta = new Vector2(24f, 24f);
			northText = (TextMeshProUGUI)(object)((Component)northRect).gameObject.AddComponent<HGTextMeshProUGUI>();
			((TMP_Text)northText).text = "N";
			((TMP_Text)northText).fontSize = 18f;
			((TMP_Text)northText).fontStyle = (FontStyles)1;
			((TMP_Text)northText).alignment = (TextAlignmentOptions)514;
			((TMP_Text)northText).enableWordWrapping = false;
			((Graphic)northText).raycastTarget = false;
			((TMP_Text)northText).outlineWidth = 0.25f;
			((TMP_Text)northText).outlineColor = new Color32((byte)0, (byte)0, (byte)0, byte.MaxValue);
		}

		public void SetVisible(bool visible)
		{
			if (Object.op_Implicit((Object)(object)Root) && ((Component)Root).gameObject.activeSelf != visible)
			{
				((Component)Root).gameObject.SetActive(visible);
			}
		}

		public void Destroy()
		{
			if (Object.op_Implicit((Object)(object)Root))
			{
				Object.Destroy((Object)(object)((Component)Root).gameObject);
			}
		}

		public void Render(Vector3 center, float yaw, CharacterBody localBody, IReadOnlyList<TrackedObject> objects, bool expanded, Texture terrain)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			float num = (expanded ? MinimapConfig.ExpandedSize.Value : MinimapConfig.Size.Value);
			float num2 = (expanded ? MinimapConfig.ExpandedZoom.Value : MinimapConfig.Zoom.Value);
			float value = MinimapConfig.BorderWidth.Value;
			MapShape value2 = MinimapConfig.Shape.Value;
			LayoutRoot(num, expanded);
			Sprite sprite = IconSprites.Mask(value2);
			border.sprite = sprite;
			((Graphic)border).color = MinimapConfig.BorderColor.Value;
			((Behaviour)border).enabled = value > 0f;
			maskImage.sprite = sprite;
			((Graphic)maskImage).color = MinimapConfig.BackgroundColor.Value;
			Stretch(maskRect, value);
			terrainImage.texture = terrain;
			((Graphic)terrainImage).color = MinimapConfig.TerrainTint.Value;
			((Behaviour)terrainImage).enabled = Object.op_Implicit((Object)(object)terrain);
			circular = value2 == MapShape.Circle;
			radius = num * 0.5f - value;
			pixelsPerMeter = radius / Mathf.Max(1f, num2);
			float num3 = (MinimapConfig.RotateWithCamera.Value ? yaw : 0f) * (MathF.PI / 180f);
			rotSin = Mathf.Sin(num3);
			rotCos = Mathf.Cos(num3);
			float num4 = num3 * 57.29578f;
			IconLayer[] array = layers;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Used = 0;
			}
			float value3 = MinimapConfig.IconScale.Value;
			float value4 = MinimapConfig.HeightThreshold.Value;
			bool value5 = MinimapConfig.HideUsed.Value;
			for (int j = 0; j < objects.Count; j++)
			{
				TrackedObject trackedObject = objects[j];
				if (!Object.op_Implicit((Object)(object)trackedObject.GameObject) || !trackedObject.GameObject.activeInHierarchy)
				{
					continue;
				}
				CategoryConfig categoryConfig = MinimapConfig.Get(trackedObject.Category);
				if (!categoryConfig.Enabled.Value)
				{
					continue;
				}
				bool isUsed = trackedObject.IsUsed;
				if (!(isUsed && value5))
				{
					Color color = (Color)(((??)trackedObject.ColorOverride) ?? categoryConfig.Color.Value);
					if (isUsed)
					{
						color.a *= 0.35f;
					}
					PlaceIcon(trackedObject.Category, categoryConfig, trackedObject.Transform.position, center, color, value3, value4, null);
				}
			}
			DrawBodies(center, localBody, value3, value4, num4);
			array = layers;
			foreach (IconLayer iconLayer in array)
			{
				for (int k = iconLayer.Used; k < iconLayer.Pool.Count; k++)
				{
					if (iconLayer.Pool[k].GameObject.activeSelf)
					{
						iconLayer.Pool[k].GameObject.SetActive(false);
					}
				}
			}
			float num5 = MinimapConfig.PlayerArrowSize.Value * value3;
			playerArrow.sizeDelta = new Vector2(num5, num5);
			playerArrow.anchoredPosition = Vector2.zero;
			((Graphic)playerArrowImage).color = MinimapConfig.PlayerArrowColor.Value;
			float num6 = (Object.op_Implicit((Object)(object)localBody) ? FacingYaw(localBody) : yaw);
			((Transform)playerArrow).localEulerAngles = new Vector3(0f, 0f, num4 - num6);
			bool value6 = MinimapConfig.ShowNorth.Value;
			((Component)northRect).gameObject.SetActive(value6);
			if (value6)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0f - rotSin, rotCos);
				float num7 = radius - 2f;
				if (!circular)
				{
					val /= Mathf.Max(Mathf.Abs(val.x), Mathf.Abs(val.y));
				}
				northRect.anchoredPosition = val * num7;
			}
		}

		private void DrawBodies(Vector3 center, CharacterBody localBody, float iconScale, float heightThreshold, float rotDegrees)
		{
			//IL_0023: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_0092: 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_00ac: 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_00b3: Invalid comparison between Unknown and I4
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			TeamIndex val = (TeamIndex)((!Object.op_Implicit((Object)(object)localBody) || !Object.op_Implicit((Object)(object)localBody.teamComponent)) ? 1 : ((int)localBody.teamComponent.teamIndex));
			ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
			for (int i = 0; i < readOnlyInstancesList.Count; i++)
			{
				CharacterBody val2 = readOnlyInstancesList[i];
				if (!Object.op_Implicit((Object)(object)val2) || (Object)(object)val2 == (Object)(object)localBody || (Object.op_Implicit((Object)(object)val2.healthComponent) && !val2.healthComponent.alive))
				{
					continue;
				}
				TeamIndex val3 = (TeamIndex)((!Object.op_Implicit((Object)(object)val2.teamComponent)) ? (-1) : ((int)val2.teamComponent.teamIndex));
				Category category;
				if (val2.isPlayerControlled)
				{
					category = ((val3 == val) ? Category.Player : Category.Enemy);
				}
				else if (val3 == val)
				{
					category = Category.Ally;
				}
				else
				{
					if ((int)val3 == 0 || (int)val3 == -1)
					{
						continue;
					}
					category = (val2.isBoss ? Category.Boss : Category.Enemy);
				}
				CategoryConfig categoryConfig = MinimapConfig.Get(category);
				if (categoryConfig.Enabled.Value)
				{
					float? rotation = ((category == Category.Player) ? new float?(rotDegrees - FacingYaw(val2)) : ((float?)null));
					PlaceIcon(category, categoryConfig, val2.corePosition, center, categoryConfig.Color.Value, iconScale, heightThreshold, rotation);
				}
			}
		}

		private void PlaceIcon(Category category, CategoryConfig cfg, Vector3 world, Vector3 center, Color color, float iconScale, float heightThreshold, float? rotation)
		{
			//IL_0059: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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)
			//IL_00c4: 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_00df: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = ((MinimapConfig.IconStyle.Value == IconStyle.Game) ? GameIcons.Get(category) : null);
			float num = (cfg.Size.Value + (Object.op_Implicit((Object)(object)val) ? MinimapConfig.GameIconSizeBonus.Value : 0f)) * iconScale;
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = IconSprites.Icon(cfg.Shape.Value);
			}
			Vector2 val2 = Project(world - center);
			float num2 = radius - num * 0.5f;
			bool num3;
			if (!circular)
			{
				if (Mathf.Abs(val2.x) > num2)
				{
					goto IL_00ad;
				}
				num3 = Mathf.Abs(val2.y) > num2;
			}
			else
			{
				num3 = ((Vector2)(ref val2)).sqrMagnitude > num2 * num2;
			}
			if (num3)
			{
				goto IL_00ad;
			}
			goto IL_00fa;
			IL_00fa:
			Icon icon = Rent(category);
			icon.Rect.anchoredPosition = val2;
			icon.Rect.sizeDelta = new Vector2(num, num);
			((Transform)icon.Rect).localEulerAngles = new Vector3(0f, 0f, rotation.GetValueOrDefault());
			icon.Image.sprite = val;
			((Graphic)icon.Image).color = color;
			float num4 = world.y - center.y;
			bool flag = heightThreshold > 0f && Mathf.Abs(num4) > heightThreshold;
			if (((Component)icon.HeightRect).gameObject.activeSelf != flag)
			{
				((Component)icon.HeightRect).gameObject.SetActive(flag);
			}
			if (flag)
			{
				float num5 = Mathf.Max(6f, num * 0.6f);
				icon.HeightRect.sizeDelta = new Vector2(num5, num5);
				icon.HeightRect.anchoredPosition = new Vector2(num * 0.5f, num * 0.5f);
				((Transform)icon.HeightRect).localEulerAngles = new Vector3(0f, 0f, ((num4 > 0f) ? 0f : 180f) - rotation.GetValueOrDefault());
				((Graphic)icon.HeightImage).color = new Color(1f, 1f, 1f, color.a);
			}
			return;
			IL_00ad:
			if (!cfg.ClampToEdge.Value)
			{
				return;
			}
			val2 = (circular ? (((Vector2)(ref val2)).normalized * num2) : (val2 / Mathf.Max(Mathf.Abs(val2.x), Mathf.Abs(val2.y)) * num2));
			goto IL_00fa;
		}

		private Vector2 Project(Vector3 offset)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			float num = offset.x * rotCos - offset.z * rotSin;
			float num2 = offset.x * rotSin + offset.z * rotCos;
			return new Vector2(num, num2) * pixelsPerMeter;
		}

		private Icon Rent(Category category)
		{
			IconLayer iconLayer = layers[(int)category];
			Icon icon;
			if (iconLayer.Used < iconLayer.Pool.Count)
			{
				icon = iconLayer.Pool[iconLayer.Used];
			}
			else
			{
				RectTransform val = NewRect("Icon", (Transform)(object)iconLayer.Container);
				Image val2 = ((Component)val).gameObject.AddComponent<Image>();
				((Graphic)val2).raycastTarget = false;
				val2.preserveAspect = true;
				RectTransform val3 = NewRect("Height", (Transform)(object)val);
				Image val4 = ((Component)val3).gameObject.AddComponent<Image>();
				val4.sprite = IconSprites.Arrow();
				((Graphic)val4).raycastTarget = false;
				((Component)val3).gameObject.SetActive(false);
				icon = new Icon
				{
					GameObject = ((Component)val).gameObject,
					Rect = val,
					Image = val2,
					HeightRect = val3,
					HeightImage = val4
				};
				iconLayer.Pool.Add(icon);
			}
			iconLayer.Used++;
			if (!icon.GameObject.activeSelf)
			{
				icon.GameObject.SetActive(true);
			}
			return icon;
		}

		private void LayoutRoot(float size, bool expanded)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			Vector2 zero = default(Vector2);
			if (expanded)
			{
				((Vector2)(ref val))..ctor(0.5f, 0.5f);
				zero = Vector2.zero;
			}
			else
			{
				float value = MinimapConfig.OffsetX.Value;
				float value2 = MinimapConfig.OffsetY.Value;
				switch (MinimapConfig.Anchor.Value)
				{
				case MapAnchor.TopRight:
					((Vector2)(ref val))..ctor(1f, 1f);
					((Vector2)(ref zero))..ctor(0f - value, 0f - value2);
					break;
				case MapAnchor.BottomLeft:
					((Vector2)(ref val))..ctor(0f, 0f);
					((Vector2)(ref zero))..ctor(value, value2);
					break;
				case MapAnchor.BottomRight:
					((Vector2)(ref val))..ctor(1f, 0f);
					((Vector2)(ref zero))..ctor(0f - value, value2);
					break;
				default:
					((Vector2)(ref val))..ctor(0f, 1f);
					((Vector2)(ref zero))..ctor(value, 0f - value2);
					break;
				}
			}
			Root.anchorMin = val;
			Root.anchorMax = val;
			Root.pivot = val;
			Root.anchoredPosition = zero;
			Root.sizeDelta = new Vector2(size, size);
			if (((Transform)Root).GetSiblingIndex() != ((Transform)Root).parent.childCount - 1)
			{
				((Transform)Root).SetAsLastSibling();
			}
		}

		private static float FacingYaw(CharacterBody body)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (Object.op_Implicit((Object)(object)body.characterDirection) ? body.characterDirection.forward : ((!Object.op_Implicit((Object)(object)body.inputBank)) ? body.transform.forward : body.inputBank.aimDirection));
			return Mathf.Atan2(val.x, val.z) * 57.29578f;
		}

		private static RectTransform NewRect(string name, Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = (Object.op_Implicit((Object)(object)parent) ? ((Component)parent).gameObject.layer : 5)
			}.transform;
			((Transform)val).SetParent(parent, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			val.pivot = val2;
			Vector2 anchorMin = (val.anchorMax = val2);
			val.anchorMin = anchorMin;
			return val;
		}

		private static void Stretch(RectTransform rect, float inset)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			rect.anchorMin = Vector2.zero;
			rect.anchorMax = Vector2.one;
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.offsetMin = new Vector2(inset, inset);
			rect.offsetMax = new Vector2(0f - inset, 0f - inset);
		}
	}
	internal enum SourceKind
	{
		Teleporter,
		Purchase,
		Picker,
		Barrel,
		Pickup,
		Generic
	}
	internal sealed class TrackedObject
	{
		public GameObject GameObject;

		public Transform Transform;

		public Category Category;

		public Component Source;

		public SourceKind Kind;

		public int Id;

		public int LastSeen;

		public bool IsUsed => Kind switch
		{
			SourceKind.Purchase => !((PurchaseInteraction)Source).available, 
			SourceKind.Picker => !((PickupPickerController)Source).available, 
			SourceKind.Barrel => ((BarrelInteraction)Source).Networkopened, 
			SourceKind.Generic => (int)((GenericInteraction)Source).interactability == 0, 
			_ => false, 
		};

		public Color? ColorOverride
		{
			get
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: 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)
				if (Kind != SourceKind.Pickup || !MinimapConfig.ItemsUseRarityColor.Value)
				{
					return null;
				}
				PickupDef pickupDef = PickupCatalog.GetPickupDef(((GenericPickupController)Source).pickup.pickupIndex);
				if (pickupDef == null)
				{
					return null;
				}
				Color baseColor = pickupDef.baseColor;
				baseColor.a = 1f;
				return baseColor;
			}
		}
	}
	internal sealed class ObjectTracker
	{
		public readonly List<TrackedObject> Objects = new List<TrackedObject>();

		private readonly Dictionary<int, TrackedObject> byGameObject = new Dictionary<int, TrackedObject>();

		private int stamp;

		public void Tick()
		{
			stamp++;
			foreach (TeleporterInteraction instances in InstanceTracker.GetInstancesList<TeleporterInteraction>())
			{
				Visit((MonoBehaviour)(object)instances, SourceKind.Teleporter);
			}
			foreach (PurchaseInteraction instances2 in InstanceTracker.GetInstancesList<PurchaseInteraction>())
			{
				Visit((MonoBehaviour)(object)instances2, SourceKind.Purchase);
			}
			foreach (PickupPickerController instances3 in InstanceTracker.GetInstancesList<PickupPickerController>())
			{
				Visit((MonoBehaviour)(object)instances3, SourceKind.Picker);
			}
			foreach (BarrelInteraction instances4 in InstanceTracker.GetInstancesList<BarrelInteraction>())
			{
				Visit((MonoBehaviour)(object)instances4, SourceKind.Barrel);
			}
			foreach (GenericPickupController instances5 in InstanceTracker.GetInstancesList<GenericPickupController>())
			{
				Visit((MonoBehaviour)(object)instances5, SourceKind.Pickup);
			}
			foreach (GenericInteraction instances6 in InstanceTracker.GetInstancesList<GenericInteraction>())
			{
				Visit((MonoBehaviour)(object)instances6, SourceKind.Generic);
			}
			for (int num = Objects.Count - 1; num >= 0; num--)
			{
				TrackedObject trackedObject = Objects[num];
				if (trackedObject.LastSeen != stamp || !Object.op_Implicit((Object)(object)trackedObject.Source))
				{
					byGameObject.Remove(trackedObject.Id);
					int index = Objects.Count - 1;
					Objects[num] = Objects[index];
					Objects.RemoveAt(index);
				}
			}
		}

		public void Clear()
		{
			Objects.Clear();
			byGameObject.Clear();
		}

		private void Visit(MonoBehaviour component, SourceKind kind)
		{
			if (Object.op_Implicit((Object)(object)component))
			{
				GameObject gameObject = ((Component)component).gameObject;
				int instanceID = ((Object)gameObject).GetInstanceID();
				if (byGameObject.TryGetValue(instanceID, out var value))
				{
					value.LastSeen = stamp;
					return;
				}
				TrackedObject trackedObject = new TrackedObject
				{
					GameObject = gameObject,
					Transform = gameObject.transform,
					Category = Classify(component, kind),
					Source = (Component)(object)component,
					Kind = kind,
					Id = instanceID,
					LastSeen = stamp
				};
				byGameObject[instanceID] = trackedObject;
				Objects.Add(trackedObject);
			}
		}

		private static Category Classify(MonoBehaviour component, SourceKind kind)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			GameObject gameObject = ((Component)component).gameObject;
			string text = ((Object)gameObject).name.ToLowerInvariant();
			switch (kind)
			{
			case SourceKind.Teleporter:
				return Category.Teleporter;
			case SourceKind.Purchase:
				return ClassifyPurchase((PurchaseInteraction)component, gameObject, text);
			case SourceKind.Picker:
				if (!text.Contains("scrapper"))
				{
					if (!text.Contains("option"))
					{
						return Category.Item;
					}
					return Category.VoidChest;
				}
				return Category.Scrapper;
			case SourceKind.Barrel:
				return Category.Barrel;
			case SourceKind.Pickup:
				return Category.Item;
			default:
				if (!text.Contains("portal"))
				{
					return Category.Other;
				}
				return Category.Portal;
			}
		}

		private static Category ClassifyPurchase(PurchaseInteraction pi, GameObject go, string name)
		{
			if (pi.isShrine || name.Contains("shrine"))
			{
				return Category.Shrine;
			}
			if (pi.isDrone || Object.op_Implicit((Object)(object)go.GetComponent<SummonMasterBehavior>()))
			{
				return Category.Drone;
			}
			if (name.Contains("duplicator"))
			{
				return Category.Printer;
			}
			if (name.Contains("cauldron"))
			{
				return Category.Cauldron;
			}
			if (Object.op_Implicit((Object)(object)go.GetComponent<PortalStatueBehavior>()) || name.Contains("newtstatue"))
			{
				return Category.NewtAltar;
			}
			if (name.Contains("lunarchest"))
			{
				return Category.LunarPod;
			}
			if (name.Contains("equipmentbarrel"))
			{
				return Category.EquipmentBarrel;
			}
			if (name.Contains("goldchest"))
			{
				return Category.LegendaryChest;
			}
			if (name.Contains("void"))
			{
				return Category.VoidChest;
			}
			if (name.Contains("categorychest"))
			{
				return Category.CategoryChest;
			}
			if (Object.op_Implicit((Object)(object)go.GetComponent<ShopTerminalBehavior>()))
			{
				return Category.Shop;
			}
			if (name.Contains("chest2"))
			{
				return Category.LargeChest;
			}
			if (Object.op_Implicit((Object)(object)go.GetComponent<ChestBehavior>()) || name.Contains("chest") || name.Contains("lockbox"))
			{
				return Category.SmallChest;
			}
			return Category.Other;
		}
	}
	internal static class RiskOfOptionsCompat
	{
		public const string GUID = "com.rune580.riskofoptions";

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Init()
		{
			ModSettingsManager.SetModDescription("Cartographer Minimap: a minimap showing chests, shrines, the teleporter, items, enemies and more.");
			Check(MinimapConfig.Enabled);
			Key(MinimapConfig.ToggleKey);
			Key(MinimapConfig.ExpandKey);
			Key(MinimapConfig.ZoomInKey);
			Key(MinimapConfig.ZoomOutKey);
			Check(MinimapConfig.HideUsed);
			Choice((ConfigEntryBase)(object)MinimapConfig.Anchor);
			Slider(MinimapConfig.OffsetX, "{0:0}");
			Slider(MinimapConfig.OffsetY, "{0:0}");
			Slider(MinimapConfig.Size, "{0:0}");
			Choice((ConfigEntryBase)(object)MinimapConfig.Shape);
			Color(MinimapConfig.BackgroundColor);
			Color(MinimapConfig.BorderColor);
			Slider(MinimapConfig.BorderWidth, "{0:0}");
			Slider(MinimapConfig.Zoom, "{0:0}m");
			Check(MinimapConfig.RotateWithCamera);
			Check(MinimapConfig.ShowNorth);
			Choice((ConfigEntryBase)(object)MinimapConfig.IconStyle);
			Slider(MinimapConfig.GameIconSizeBonus, "+{0:0}");
			Slider(MinimapConfig.IconScale, "{0:0.00}x");
			Slider(MinimapConfig.HeightThreshold, "{0:0}m");
			Check(MinimapConfig.ItemsUseRarityColor);
			Color(MinimapConfig.PlayerArrowColor);
			Slider(MinimapConfig.PlayerArrowSize, "{0:0}");
			Slider(MinimapConfig.ExpandedSize, "{0:0}");
			Slider(MinimapConfig.ExpandedZoom, "{0:0}m");
			Check(MinimapConfig.ShowTerrain);
			IntSlider(MinimapConfig.TerrainResolution);
			IntSlider(MinimapConfig.TerrainFps);
			Slider(MinimapConfig.TerrainCeiling, "{0:0}m");
			Slider(MinimapConfig.TerrainDepth, "{0:0}m");
			Color(MinimapConfig.TerrainTint);
			CategoryConfig[] categories = MinimapConfig.Categories;
			foreach (CategoryConfig obj in categories)
			{
				Check(obj.Enabled);
				Color(obj.Color);
				Choice((ConfigEntryBase)(object)obj.Shape);
				Slider(obj.Size, "{0:0}");
				Check(obj.ClampToEdge);
			}
		}

		private static void Check(ConfigEntry<bool> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry));
		}

		private static void Key(ConfigEntry<KeyboardShortcut> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry));
		}

		private static void Color(ConfigEntry<Color> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ColorOption(entry));
		}

		private static void Choice(ConfigEntryBase entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption(entry));
		}

		private static void Slider(ConfigEntry<float> entry, string format)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			AcceptableValueRange<float> val = ((ConfigEntryBase)entry).Description.AcceptableValues as AcceptableValueRange<float>;
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = (val?.MinValue ?? 0f),
				max = (val?.MaxValue ?? 100f),
				FormatString = format
			}));
		}

		private static void IntSlider(ConfigEntry<int> entry)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			AcceptableValueRange<int> val = ((ConfigEntryBase)entry).Description.AcceptableValues as AcceptableValueRange<int>;
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = (val?.MinValue ?? 0),
				max = (val?.MaxValue ?? 100)
			}));
		}
	}
	internal sealed class TerrainRenderer
	{
		private const float CameraAltitude = 1500f;

		private Camera camera;

		private RenderTexture cameraTarget;

		private RenderTexture output;

		private Material opaqueBlit;

		private bool triedOpaqueBlit;

		private float timeUntilRender;

		public Texture Texture
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)output))
				{
					return (Texture)(object)cameraTarget;
				}
				return (Texture)(object)output;
			}
		}

		public void Render(Vector3 center, float yaw, float zoom, int resolution, float deltaTime)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f / (float)Mathf.Max(1, MinimapConfig.TerrainFps.Value);
			timeUntilRender -= deltaTime;
			if (timeUntilRender > 0f && Object.op_Implicit((Object)(object)cameraTarget))
			{
				return;
			}
			timeUntilRender = Mathf.Max(timeUntilRender + num, 0f);
			EnsureResources(resolution);
			float value = MinimapConfig.TerrainCeiling.Value;
			float value2 = MinimapConfig.TerrainDepth.Value;
			Transform transform = ((Component)camera).transform;
			transform.position = center + Vector3.up * 1500f;
			transform.rotation = Quaternion.Euler(90f, yaw, 0f);
			camera.nearClipPlane = Mathf.Max(0.3f, 1500f - value);
			camera.farClipPlane = 1500f + value2;
			camera.fieldOfView = 2f * Mathf.Atan(zoom / 1500f) * 57.29578f;
			camera.cullingMask = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask);
			bool fog = RenderSettings.fog;
			float shadowDistance = QualitySettings.shadowDistance;
			try
			{
				RenderSettings.fog = false;
				QualitySettings.shadowDistance = 0f;
				camera.Render();
			}
			catch (Exception ex)
			{
				CartographerPlugin.Log.LogWarning((object)("Terrain render failed: " + ex.Message));
			}
			finally
			{
				RenderSettings.fog = fog;
				QualitySettings.shadowDistance = shadowDistance;
			}
			if (Object.op_Implicit((Object)(object)output) && Object.op_Implicit((Object)(object)opaqueBlit))
			{
				Graphics.Blit((Texture)(object)cameraTarget, output, opaqueBlit);
			}
		}

		private void EnsureResources(int resolution)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			resolution = Mathf.Clamp(resolution, 32, 2048);
			if (!Object.op_Implicit((Object)(object)camera))
			{
				GameObject val = new GameObject("Cartographer Terrain Camera");
				Object.DontDestroyOnLoad((Object)(object)val);
				((Object)val).hideFlags = (HideFlags)61;
				camera = val.AddComponent<Camera>();
				((Behaviour)camera).enabled = false;
				camera.clearFlags = (CameraClearFlags)2;
				camera.backgroundColor = new Color(0f, 0f, 0f, 0f);
				camera.orthographic = false;
				camera.aspect = 1f;
				camera.allowHDR = false;
				camera.allowMSAA = false;
				camera.useOcclusionCulling = false;
				camera.renderingPath = (RenderingPath)3;
				camera.depth = -100f;
			}
			if (!triedOpaqueBlit)
			{
				triedOpaqueBlit = true;
				Shader val2 = Shader.Find("Unlit/Texture");
				if (Object.op_Implicit((Object)(object)val2))
				{
					opaqueBlit = new Material(val2)
					{
						hideFlags = (HideFlags)61
					};
				}
				else
				{
					CartographerPlugin.Log.LogInfo((object)"Unlit/Texture shader not found; terrain alpha is used as-is.");
				}
			}
			if (!Object.op_Implicit((Object)(object)cameraTarget) || ((Texture)cameraTarget).width != resolution)
			{
				Release(ref cameraTarget);
				Release(ref output);
				cameraTarget = NewTexture(resolution, 24);
				if (Object.op_Implicit((Object)(object)opaqueBlit))
				{
					output = NewTexture(resolution, 0);
				}
				camera.targetTexture = cameraTarget;
			}
		}

		private static RenderTexture NewTexture(int resolution, int depth)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			RenderTexture val = new RenderTexture(resolution, resolution, depth, (RenderTextureFormat)0)
			{
				name = "Cartographer Terrain",
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				antiAliasing = 1,
				hideFlags = (HideFlags)61
			};
			val.Create();
			return val;
		}

		private static void Release(ref RenderTexture rt)
		{
			if (Object.op_Implicit((Object)(object)rt))
			{
				rt.Release();
				Object.Destroy((Object)(object)rt);
				rt = null;
			}
		}

		public void Dispose()
		{
			if (Object.op_Implicit((Object)(object)camera))
			{
				Object.Destroy((Object)(object)((Component)camera).gameObject);
			}
			camera = null;
			Release(ref cameraTarget);
			Release(ref output);
		}
	}
	public enum Category
	{
		Teleporter,
		Portal,
		SmallChest,
		LargeChest,
		LegendaryChest,
		CategoryChest,
		LunarPod,
		EquipmentBarrel,
		VoidChest,
		Shop,
		Printer,
		Scrapper,
		Cauldron,
		Shrine,
		NewtAltar,
		Drone,
		Barrel,
		Item,
		Other,
		Enemy,
		Boss,
		Ally,
		Player
	}
	public enum IconShape
	{
		Circle,
		Square,
		Diamond,
		Triangle,
		Ring,
		Star,
		Cross
	}
	public enum IconStyle
	{
		Game,
		Shapes
	}
	public enum MapAnchor
	{
		TopLeft,
		TopRight,
		BottomLeft,
		BottomRight
	}
	public enum MapShape
	{
		Circle,
		Square
	}
	internal readonly struct CategoryDefaults
	{
		public readonly string Description;

		public readonly Color Color;

		public readonly IconShape Shape;

		public readonly float Size;

		public readonly bool ClampToEdge;

		public readonly bool Enabled;

		public CategoryDefaults(string description, Color color, IconShape shape, float size, bool clampToEdge = false, bool enabled = true)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Description = description;
			Color = color;
			Shape = shape;
			Size = size;
			ClampToEdge = clampToEdge;
			Enabled = enabled;
		}

		public static CategoryDefaults For(Category category)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			return category switch
			{
				Category.Teleporter => new CategoryDefaults("The stage teleporter (and primordial teleporter).", new Color(1f, 0.3f, 0.3f), IconShape.Star, 24f, clampToEdge: true), 
				Category.Portal => new CategoryDefaults("Bazaar, gold, celestial, void and other portals.", new Color(0.45f, 0.85f, 1f), IconShape.Ring, 18f, clampToEdge: true), 
				Category.SmallChest => new CategoryDefaults("Small chests, cloaked chests, adaptive chests and rusty lockboxes.", new Color(0.95f, 0.95f, 0.95f), IconShape.Square, 10f), 
				Category.LargeChest => new CategoryDefaults("Large chests.", new Color(0.47f, 0.89f, 0.29f), IconShape.Square, 13f), 
				Category.LegendaryChest => new CategoryDefaults("Legendary chests.", new Color(0.9f, 0.2f, 0.2f), IconShape.Square, 16f, clampToEdge: true), 
				Category.CategoryChest => new CategoryDefaults("Damage / healing / utility chests.", new Color(1f, 0.75f, 0.4f), IconShape.Square, 11f), 
				Category.LunarPod => new CategoryDefaults("Lunar pods.", new Color(0.37f, 0.62f, 1f), IconShape.Diamond, 12f), 
				Category.EquipmentBarrel => new CategoryDefaults("Equipment barrels.", new Color(1f, 0.55f, 0.1f), IconShape.Square, 11f), 
				Category.VoidChest => new CategoryDefaults("Void cradles and void potentials.", new Color(0.85f, 0.35f, 0.95f), IconShape.Diamond, 12f), 
				Category.Shop => new CategoryDefaults("Multishop terminals and lunar buds.", new Color(0.3f, 0.85f, 0.85f), IconShape.Square, 10f), 
				Category.Printer => new CategoryDefaults("3D printers.", new Color(1f, 0.85f, 0.3f), IconShape.Diamond, 12f), 
				Category.Scrapper => new CategoryDefaults("Scrappers.", new Color(0.75f, 0.75f, 0.75f), IconShape.Cross, 12f), 
				Category.Cauldron => new CategoryDefaults("Lunar cauldrons (Bazaar).", new Color(0.45f, 0.55f, 1f), IconShape.Ring, 12f), 
				Category.Shrine => new CategoryDefaults("All shrines (chance, blood, combat, mountain, order, woods, cleansing pools...).", new Color(0.55f, 0.9f, 1f), IconShape.Triangle, 12f), 
				Category.NewtAltar => new CategoryDefaults("Newt altars (blue orb portal statues).", new Color(0.4f, 0.75f, 1f), IconShape.Diamond, 12f), 
				Category.Drone => new CategoryDefaults("Purchasable drones and turrets.", new Color(0.75f, 0.85f, 0.95f), IconShape.Triangle, 10f), 
				Category.Barrel => new CategoryDefaults("Money barrels.", new Color(0.85f, 0.7f, 0.4f), IconShape.Circle, 7f), 
				Category.Item => new CategoryDefaults("Items and equipment lying on the ground, command essences.", Color.white, IconShape.Circle, 8f), 
				Category.Other => new CategoryDefaults("Any other interactable that doesn't fit a category above.", new Color(0.7f, 0.7f, 0.7f), IconShape.Circle, 7f), 
				Category.Enemy => new CategoryDefaults("Enemies.", new Color(1f, 0.2f, 0.2f), IconShape.Circle, 6f), 
				Category.Boss => new CategoryDefaults("Bosses (teleporter bosses, elite champions...).", new Color(1f, 0.4f, 0f), IconShape.Diamond, 14f, clampToEdge: true), 
				Category.Ally => new CategoryDefaults("Your minions, drones and other allied NPCs.", new Color(0.4f, 1f, 0.4f), IconShape.Circle, 6f), 
				Category.Player => new CategoryDefaults("Other players on your team.", new Color(0.3f, 0.7f, 1f), IconShape.Triangle, 12f, clampToEdge: true), 
				_ => new CategoryDefaults("", Color.white, IconShape.Circle, 8f), 
			};
		}
	}
}