Decompiled source of Minimap v1.1.0

MinimapMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using CellMenu;
using GTFO.API.Utilities;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Player;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MinimapMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MinimapMod")]
[assembly: AssemblyTitle("MinimapMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MinimapMod;

[BepInPlugin("minimap.HazardousMonkey", "MinimapMod", "1.1.0")]
public class MinimapPlugin : BasePlugin
{
	public static ConfigEntry<float> MapScale;

	public static ConfigEntry<string> MapBackgroundZoomColor;

	public static ConfigEntry<float> OffsetX;

	public static ConfigEntry<float> OffsetY;

	public static ConfigEntry<string> AnchorX;

	public static ConfigEntry<string> AnchorY;

	public static ConfigEntry<KeyCode> ToggleKey;

	public static ConfigEntry<KeyCode> ZoomKey;

	public static ConfigEntry<bool> SuppressInventoryOnZoom;

	public static ConfigEntry<bool> MapMatchPlayerRotation;

	public static ConfigEntry<string> MapShape;

	public static ConfigEntry<int> MapUpdateRate;

	public static ConfigEntry<int> PlayerLineThickness;

	public static ConfigEntry<float> PlayerIconScale;

	public static ConfigEntry<float> MinimapObjectIconScale;

	public static ConfigEntry<bool> ShowLocationLabel;

	public static ConfigEntry<string> LocationLabelPosition;

	public static ConfigEntry<int> LocationLabelFontSize;

	public static ConfigEntry<string> LocationLabelFont;

	public static ConfigEntry<string> LabelOutlineColor;

	public static ConfigEntry<float> LabelOutlineThickness;

	public static ConfigEntry<bool> DetectCombatState;

	public static ConfigEntry<string> ColorElevatorIdle;

	public static ConfigEntry<string> ColorElevatorGoingDown;

	public static ConfigEntry<string> ColorUndetected;

	public static ConfigEntry<string> ColorEncounter;

	public static ConfigEntry<string> ColorCombat;

	public static ConfigEntry<string> ColorSurvival;

	public static ConfigEntry<string> ColorIntentionalCombat;

	public static ConfigEntry<bool> ShowCompass;

	public static ConfigEntry<int> CompassFontSize;

	public static ConfigEntry<string> CompassNorthColor;

	public static ConfigEntry<string> CompassSouthColor;

	public static ConfigEntry<string> CompassEastColor;

	public static ConfigEntry<string> CompassWestColor;

	public static ConfigEntry<float> MinimapOpacity;

	public const int MinimapLayer = 31;

	public static int UILayer = -1;

	public static MinimapPlugin Instance { get; private set; }

	public static bool DimensionMapsInstalled { get; private set; }

	public override void Load()
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Expected O, but got Unknown
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Expected O, but got Unknown
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Expected O, but got Unknown
		//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_061a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0624: Expected O, but got Unknown
		Instance = this;
		DimensionMapsInstalled = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("dev.aurirex.gtfo.dimensionmaps");
		((BasePlugin)this).Log.LogInfo((object)("[MinimapMod] DimensionMaps: " + (DimensionMapsInstalled ? "detected" : "not found") + "."));
		MapShape = ((BasePlugin)this).Config.Bind<string>("Shape and Position", "Shape", "Square", new ConfigDescription("Minimap shape.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Square", "Circle" }), Array.Empty<object>()));
		MapScale = ((BasePlugin)this).Config.Bind<float>("Shape and Position", "Scale", 0.3f, "Size of the minimap panel as a fraction of screen size (0.1 - 1.0)");
		MinimapOpacity = ((BasePlugin)this).Config.Bind<float>("Shape and Position", "Opacity", 1f, new ConfigDescription("Overall opacity of the minimap overlay (0.0 = fully transparent, 1.0 = fully opaque).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		AnchorX = ((BasePlugin)this).Config.Bind<string>("Shape and Position", "AnchorX", "Right", new ConfigDescription("Horizontal screen edge to anchor the minimap to.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Left", "Right" }), Array.Empty<object>()));
		AnchorY = ((BasePlugin)this).Config.Bind<string>("Shape and Position", "AnchorY", "Bottom", new ConfigDescription("Vertical screen edge to anchor the minimap to.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Top", "Bottom" }), Array.Empty<object>()));
		OffsetX = ((BasePlugin)this).Config.Bind<float>("Shape and Position", "OffsetX", 16f, "Distance in pixels inward from the chosen horizontal edge.");
		OffsetY = ((BasePlugin)this).Config.Bind<float>("Shape and Position", "OffsetY", 16f, "Distance in pixels inward from the chosen vertical edge.");
		MapMatchPlayerRotation = ((BasePlugin)this).Config.Bind<bool>("General Functions", "Match player rotation (False disables compass)", true, "Minimap rotates to match your facing direction");
		ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("General Functions", "ToggleKey", (KeyCode)109, "Key to show/hide the minimap");
		ZoomKey = ((BasePlugin)this).Config.Bind<KeyCode>("General Functions", "ZoomKey", (KeyCode)308, "Hold this key while scrolling to zoom the minimap.");
		SuppressInventoryOnZoom = ((BasePlugin)this).Config.Bind<bool>("General Functions", "SuppressInventoryOnZoom", true, "Holding ZoomKey prevents weapon switching while scrolling. ");
		MapBackgroundZoomColor = ((BasePlugin)this).Config.Bind<string>("General Functions", "MapBackgroundZoomColor", "#ff9933", "Color of the minimap background while ZoomKey is held (hex #rrggbb)");
		PlayerLineThickness = ((BasePlugin)this).Config.Bind<int>("General Functions", "PlayerLineThickness", 5, "Thickness of player-to-player lines on the minimap in world units (0 = off)");
		PlayerIconScale = ((BasePlugin)this).Config.Bind<float>("General Functions", "PlayerIconScale", 2f, "Scale multiplier applied to player icons on the minimap 1.0 = game default, 2.0 = double size, etc");
		MinimapObjectIconScale = ((BasePlugin)this).Config.Bind<float>("General Functions", "MinimapObjectIconScale", 2f, "Scale multiplier applied to map object icons (doors, lockers, terminals, ladders, etc.) on the minimap. CM_MapSign items are excluded as they lack a centered origin. 1.0 = game default, 2.0 = double size, etc");
		MapUpdateRate = ((BasePlugin)this).Config.Bind<int>("General Functions", "UpdateRate", 0, "Frames between minimap data ticks. 0 = every frame (smoothest) Higher values reduce CPU cost but obviously will look worse");
		ShowLocationLabel = ((BasePlugin)this).Config.Bind<bool>("Zone label", "ShowLocationLabel", true, "Reveal what Zone & Area you're in above the minimap. Updated every 0.25 seconds");
		LocationLabelPosition = ((BasePlugin)this).Config.Bind<string>("Zone label", "Label Position (might require Offset adjustment)", "Top", new ConfigDescription("Position of the zone label relative to the minimap edge. Top = floats above, Bottom = floats below.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Top", "Bottom" }), Array.Empty<object>()));
		LocationLabelFontSize = ((BasePlugin)this).Config.Bind<int>("Zone label", "LocationLabelFontSize", 24, "Font size of the Zone|Area label displayed near the minimap");
		LocationLabelFont = ((BasePlugin)this).Config.Bind<string>("Zone label", "Font", "Arial", "Font name for the Zone|Area label. Must be a Unity built-in resource name (e.g. \"Arial\"). Falls back to Arial if the name is not found.");
		LabelOutlineColor = ((BasePlugin)this).Config.Bind<string>("Zone label", "OutlineColor", "#000000", "Color of the text outline stroke (hex #rrggbb). Applied once at first level load — requires a game restart to change.");
		LabelOutlineThickness = ((BasePlugin)this).Config.Bind<float>("Zone label", "OutlineThickness", 2f, "Pixel radius of the text outline stroke. Applied once at first level load — requires a game restart to change.");
		DetectCombatState = ((BasePlugin)this).Config.Bind<bool>("Zone label", "DetectCombatState (2 second delay)", true, "Zone label changes color to reflect the current drama state (Undetected, Scout wave, Door Alarm, etc). There's a 2 second delay in color changes to avoid balance concerns");
		ColorElevatorIdle = ((BasePlugin)this).Config.Bind<string>("Zone label", "ElevatorIdle", "#ffffff", "Level not yet started, obviously (hex #rrggbb)");
		ColorElevatorGoingDown = ((BasePlugin)this).Config.Bind<string>("Zone label", "ElevatorGoingDown", "#ffffff", "Level not yet started, obviously (hex #rrggbb)");
		ColorUndetected = ((BasePlugin)this).Config.Bind<string>("Zone label", "Undetected", "#1ae08c", "Label color while undetected (hex #rrggbb)");
		ColorEncounter = ((BasePlugin)this).Config.Bind<string>("Zone label", "Encounter", "#ffa600", "Label color while generally detected (hex #rrggbb)");
		ColorCombat = ((BasePlugin)this).Config.Bind<string>("Zone label", "Combat", "#ffff00", "Label color while fighting several sleepers (hex #rrggbb)");
		ColorSurvival = ((BasePlugin)this).Config.Bind<string>("Zone label", "Survival", "#00ffff", "Label color during Scout & Reactor waves (hex #rrggbb)");
		ColorIntentionalCombat = ((BasePlugin)this).Config.Bind<string>("Zone label", "IntentionalCombat", "#ff0000", "Label color during Door Alert wave (hex #rrggbb)");
		ShowCompass = ((BasePlugin)this).Config.Bind<bool>("Compass", "Show Compass (Requires ► Match Player Rotation)", true, "Show N/S/E/W compass labels around the minimap edge. Most useful when MapMatchPlayerRotation is enabled.");
		CompassFontSize = ((BasePlugin)this).Config.Bind<int>("Compass", "FontSize", 22, "Font size for the compass direction labels.");
		CompassNorthColor = ((BasePlugin)this).Config.Bind<string>("Compass", "NorthColor", "#1ae08c", "Color of the North (N) compass label (hex #rrggbb) (Green = default).");
		CompassSouthColor = ((BasePlugin)this).Config.Bind<string>("Compass", "SouthColor", "#ff0000", "Color of the South (S) compass label (hex #rrggbb) (Red = default).");
		CompassEastColor = ((BasePlugin)this).Config.Bind<string>("Compass", "EastColor", "#3ca3ff", "Color of the East (E) compass label (hex #rrggbb) (Blue = default).");
		CompassWestColor = ((BasePlugin)this).Config.Bind<string>("Compass", "WestColor", "#ffe600", "Color of the West (W) compass label (hex #rrggbb) (Yellow = default).");
		ClassInjector.RegisterTypeInIl2Cpp<MinimapToggler>();
		new Harmony("minimap.HazardousMonkey").PatchAll();
		LiveEdit.CreateListener(Paths.ConfigPath, Path.GetFileName(((BasePlugin)this).Config.ConfigFilePath), false).FileChanged += (LiveEditEventHandler)delegate
		{
			((BasePlugin)this).Config.Reload();
			MinimapManager.MarkConfigDirty();
		};
		((BasePlugin)this).Log.LogInfo((object)"MinimapMod loaded.");
	}
}
public static class OverlayCanvasManager
{
	public static GameObject CanvasRoot { get; private set; }

	public static CanvasGroup CanvasGroup { get; private set; }

	public static void EnsureCreated()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)CanvasRoot != (Object)null && ((Il2CppObjectBase)CanvasRoot).Pointer != IntPtr.Zero)
		{
			return;
		}
		try
		{
			CanvasRoot = new GameObject("MinimapOverlayCanvas");
			Object.DontDestroyOnLoad((Object)(object)CanvasRoot);
			Canvas obj = ((Il2CppObjectBase)CanvasRoot.AddComponent(Il2CppType.Of<Canvas>())).Cast<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 50;
			CanvasScaler obj2 = ((Il2CppObjectBase)CanvasRoot.AddComponent(Il2CppType.Of<CanvasScaler>())).Cast<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			CanvasGroup obj3 = ((Il2CppObjectBase)CanvasRoot.AddComponent(Il2CppType.Of<CanvasGroup>())).Cast<CanvasGroup>();
			obj3.alpha = MinimapPlugin.MinimapOpacity.Value;
			obj3.interactable = false;
			obj3.blocksRaycasts = false;
			CanvasGroup = obj3;
		}
		catch (Exception value)
		{
			Debug.LogError(Object.op_Implicit($"[MinimapMod] Failed to create overlay canvas: {value}"));
			CanvasRoot = null;
			CanvasGroup = null;
		}
	}
}
public static class ZoneAreaTracker
{
	private const float _tickInterval = 0.25f;

	private static float _nextTickTime = 0f;

	public static string CachedLabel { get; private set; } = "";


	public static void Reset()
	{
		_nextTickTime = 0f;
		CachedLabel = "";
	}

	public static void Tick()
	{
		if (!(Time.time < _nextTickTime))
		{
			_nextTickTime = Time.time + 0.25f;
			CachedLabel = BuildLabel();
		}
	}

	private static string LayerSuffix(LG_LayerType type)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		if ((int)type != 1)
		{
			if ((int)type == 2)
			{
				return "c";
			}
			return "";
		}
		return "b";
	}

	private static string BuildLabel()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			PlayerAgent localPlayerAgent = MinimapManager.LocalPlayerAgent;
			if ((Object)(object)localPlayerAgent == (Object)null || ((Il2CppObjectBase)localPlayerAgent).Pointer == IntPtr.Zero)
			{
				return "";
			}
			AIG_CourseNode courseNode = ((Agent)localPlayerAgent).CourseNode;
			if (courseNode == null || ((Il2CppObjectBase)courseNode).Pointer == IntPtr.Zero)
			{
				return "";
			}
			LG_Area area = courseNode.m_area;
			if ((Object)(object)area == (Object)null || ((Il2CppObjectBase)area).Pointer == IntPtr.Zero)
			{
				return "";
			}
			LG_Zone zone = area.m_zone;
			if ((Object)(object)zone == (Object)null || ((Il2CppObjectBase)zone).Pointer == IntPtr.Zero)
			{
				return "";
			}
			string value = ((zone.Layer != null) ? LayerSuffix(zone.Layer.m_type) : "");
			string text = $"Zone {zone.Alias}{value}";
			string text2 = "Area ?";
			List<LG_Area> areas = zone.m_areas;
			if (areas != null)
			{
				for (int i = 0; i < areas.Count; i++)
				{
					try
					{
						LG_Area val = areas[i];
						if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)area).Pointer)
						{
							text2 = "Area " + (char)(65 + i);
							break;
						}
					}
					catch
					{
					}
				}
			}
			return text + "  |  " + text2;
		}
		catch (Exception ex)
		{
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] ZoneAreaTracker.BuildLabel failed: " + ex.Message));
			return "";
		}
	}
}
public static class MinimapManager
{
	public static CM_PageMap MapPageInstance;

	public static bool IsTickingUpdate = false;

	private static volatile bool _configDirty = false;

	private static CM_PageMap _cachedMapPage;

	private static bool _isVisible = true;

	private static bool _isFullMapOpen = false;

	private static bool _isMenuLayerActive = false;

	private static bool _isInNonRealityDimension = false;

	private static bool _isCameraEnabledByPlayerLayer = false;

	private static bool _playerIconScaleApplied = false;

	private static bool _objectIconScaleApplied = false;

	private static Camera _minimapCamera;

	private static RenderTexture _minimapRT;

	private static float _minimapScale = 2f;

	private static float _fullmapScale = 2f;

	private static GameObject _mapHolderHost;

	private static GameObject _mapHolderInstance;

	private static Transform _mapHolderOriginalParent;

	private static int _mapHolderOriginalLayer = 5;

	private static readonly List<GameObject> _mapHolderAllObjects = new List<GameObject>(64);

	private static int _cachedMapHolderChildCount = -1;

	private static Transform _mapMover;

	private static Transform _mapMoverElements;

	private static Transform _localPlayerMapItem;

	private static PlayerAgent _localPlayerAgent;

	private static PlayerLocomotion _localPlayerLoco;

	private static GameObject _chatBoxActive;

	private static eDimensionIndex _lastKnownDimension = (eDimensionIndex)(-1);

	private static readonly List<SpriteRenderer> _mapSpriteRenderers = new List<SpriteRenderer>(2);

	private static readonly List<Material> _mapSpriteMats = new List<Material>(2);

	private static readonly List<Texture> _gridTileOriginals = new List<Texture>(2);

	private static readonly Texture2D _blankGridTile = CreateBlankGridTile();

	private static readonly List<GameObject> _playerLineObjects = new List<GameObject>(4);

	private static readonly List<Transform> _cachedPlayerItems = new List<Transform>(4);

	private static readonly List<LineRenderer> _cachedLineRenderers = new List<LineRenderer>(4);

	private static int _playerLineInsertionIndex = -1;

	private static Shader _spriteDefaultShader = null;

	private static float _playerCountNextCheckTime = 0f;

	private static Text _locationLabel;

	private static string _lastLabelText = null;

	private static DRAMA_State _lastDramaState = (DRAMA_State)2;

	private static DRAMA_State _pendingDramaState = (DRAMA_State)2;

	private static float _pendingStateTime = -1f;

	private static Graphic _backgroundGraphic = null;

	private static Graphic _borderGraphic = null;

	private static bool _wasZoomHeld = false;

	private static Color? _cachedZoomColor = null;

	private static Color? _cachedBorderColor = null;

	private static Sprite _circleSprite = null;

	private static GameObject _compassRoot = null;

	private static RectTransform[] _compassLabelRects = null;

	private static float _compassRadius = 0f;

	private static float _lastCompassY = float.NaN;

	private static KeyCode _cfgToggleKey = (KeyCode)109;

	public static KeyCode _cfgZoomKey = (KeyCode)308;

	private static int _cfgPlayerLineThickness = 5;

	private static bool _cfgShowLocationLabel = true;

	private static bool _cfgDetectCombatState = true;

	private static bool _cfgMatchRotation = true;

	private static bool _cfgShowCompass = true;

	public static bool _cfgSuppressInventory = true;

	private static float _snapMapScale;

	private static string _snapMapShape;

	private static string _snapAnchorX;

	private static string _snapAnchorY;

	private static float _snapOffsetX;

	private static float _snapOffsetY;

	private static string _snapMapBackgroundZoomColor;

	private static KeyCode _snapToggleKey;

	private static KeyCode _snapZoomKey;

	private static bool _snapSuppressInventory;

	private static bool _snapMatchRotation;

	private static int _snapMapUpdateRate;

	private static int _snapPlayerLineThickness;

	private static float _snapPlayerIconScale;

	private static float _snapMinimapObjectIconScale;

	private static bool _snapShowLocationLabel;

	private static string _snapLocationLabelPosition;

	private static int _snapLocationLabelFontSize;

	private static string _snapLocationLabelFont;

	private static string _snapLabelOutlineColor;

	private static float _snapLabelOutlineThickness;

	private static bool _snapDetectCombatState;

	private static string _snapColorElevatorIdle;

	private static string _snapColorElevatorGoingDown;

	private static string _snapColorUndetected;

	private static string _snapColorEncounter;

	private static string _snapColorCombat;

	private static string _snapColorSurvival;

	private static string _snapColorIntentionalCombat;

	private static Color _cachedColorElevatorIdle;

	private static Color _cachedColorElevatorGoingDown;

	private static Color _cachedColorUndetected;

	private static Color _cachedColorEncounter;

	private static Color _cachedColorCombat;

	private static Color _cachedColorSurvival;

	private static Color _cachedColorIntentionalCombat;

	private static readonly Color _cachedColorDramaDefault = new Color(0.9f, 0.9f, 0.9f, 1f);

	private static bool _snapShowCompass;

	private static int _snapCompassFontSize;

	private static string _snapCompassNorthColor;

	private static string _snapCompassSouthColor;

	private static string _snapCompassEastColor;

	private static string _snapCompassWestColor;

	private static float _snapMinimapOpacity;

	public static GameObject BackgroundPanel { get; private set; }

	public static GameObject MinimapDisplay { get; private set; }

	public static bool IsFullMapOpen => _isFullMapOpen;

	public static bool IsLabelEnabled => _cfgShowLocationLabel;

	public static PlayerAgent LocalPlayerAgent => _localPlayerAgent;

	public static int SnapMapUpdateRate => _snapMapUpdateRate;

	public static void MarkConfigDirty()
	{
		_configDirty = true;
	}

	public static bool ConsumeConfigDirty()
	{
		if (!_configDirty)
		{
			return false;
		}
		_configDirty = false;
		return true;
	}

	public static void CacheMapPage(CM_PageMap page)
	{
		_cachedMapPage = page;
	}

	public static void SetChatBoxActive(GameObject go)
	{
		_chatBoxActive = go;
	}

	private static Texture2D CreateBlankGridTile()
	{
		//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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
		val.SetPixel(0, 0, Color.clear);
		val.Apply();
		return val;
	}

	public static void CacheHotConfig()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		_cfgToggleKey = MinimapPlugin.ToggleKey.Value;
		_cfgZoomKey = MinimapPlugin.ZoomKey.Value;
		_cfgPlayerLineThickness = MinimapPlugin.PlayerLineThickness.Value;
		_cfgShowLocationLabel = MinimapPlugin.ShowLocationLabel.Value;
		_cfgDetectCombatState = MinimapPlugin.DetectCombatState.Value;
		_cfgMatchRotation = MinimapPlugin.MapMatchPlayerRotation.Value;
		_cfgShowCompass = MinimapPlugin.ShowCompass.Value;
		_cfgSuppressInventory = MinimapPlugin.SuppressInventoryOnZoom.Value;
		SnapshotLiveConfig();
	}

	private static void SnapshotLiveConfig()
	{
		//IL_006e: 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_007d: 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_01cc: 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_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		_snapMapScale = MinimapPlugin.MapScale.Value;
		_snapMapShape = MinimapPlugin.MapShape.Value;
		_snapAnchorX = MinimapPlugin.AnchorX.Value;
		_snapAnchorY = MinimapPlugin.AnchorY.Value;
		_snapOffsetX = MinimapPlugin.OffsetX.Value;
		_snapOffsetY = MinimapPlugin.OffsetY.Value;
		_snapMapBackgroundZoomColor = MinimapPlugin.MapBackgroundZoomColor.Value;
		_snapToggleKey = MinimapPlugin.ToggleKey.Value;
		_snapZoomKey = MinimapPlugin.ZoomKey.Value;
		_snapSuppressInventory = MinimapPlugin.SuppressInventoryOnZoom.Value;
		_snapMatchRotation = MinimapPlugin.MapMatchPlayerRotation.Value;
		_snapMapUpdateRate = MinimapPlugin.MapUpdateRate.Value;
		_snapPlayerLineThickness = MinimapPlugin.PlayerLineThickness.Value;
		_snapPlayerIconScale = MinimapPlugin.PlayerIconScale.Value;
		_snapMinimapObjectIconScale = MinimapPlugin.MinimapObjectIconScale.Value;
		_snapShowLocationLabel = MinimapPlugin.ShowLocationLabel.Value;
		_snapLocationLabelPosition = MinimapPlugin.LocationLabelPosition.Value;
		_snapLocationLabelFontSize = MinimapPlugin.LocationLabelFontSize.Value;
		_snapLocationLabelFont = MinimapPlugin.LocationLabelFont.Value;
		_snapLabelOutlineColor = MinimapPlugin.LabelOutlineColor.Value;
		_snapLabelOutlineThickness = MinimapPlugin.LabelOutlineThickness.Value;
		_snapDetectCombatState = MinimapPlugin.DetectCombatState.Value;
		_snapColorElevatorIdle = MinimapPlugin.ColorElevatorIdle.Value;
		_snapColorElevatorGoingDown = MinimapPlugin.ColorElevatorGoingDown.Value;
		_snapColorUndetected = MinimapPlugin.ColorUndetected.Value;
		_snapColorEncounter = MinimapPlugin.ColorEncounter.Value;
		_snapColorCombat = MinimapPlugin.ColorCombat.Value;
		_snapColorSurvival = MinimapPlugin.ColorSurvival.Value;
		_snapColorIntentionalCombat = MinimapPlugin.ColorIntentionalCombat.Value;
		_cachedColorElevatorIdle = ParseColor(_snapColorElevatorIdle, new Color(0.75f, 0.75f, 0.75f, 1f), "ColorElevatorIdle");
		_cachedColorElevatorGoingDown = ParseColor(_snapColorElevatorGoingDown, new Color(0.75f, 0.75f, 0.75f, 1f), "ColorElevatorGoingDown");
		_cachedColorUndetected = ParseColor(_snapColorUndetected, new Color(0.1f, 0.88f, 0.55f, 1f), "ColorUndetected");
		_cachedColorEncounter = ParseColor(_snapColorEncounter, new Color(1f, 0.55f, 0.1f, 1f), "ColorEncounter");
		_cachedColorCombat = ParseColor(_snapColorCombat, new Color(1f, 1f, 0f, 1f), "ColorCombat");
		_cachedColorSurvival = ParseColor(_snapColorSurvival, new Color(0.85f, 0.05f, 0.05f, 1f), "ColorSurvival");
		_cachedColorIntentionalCombat = ParseColor(_snapColorIntentionalCombat, new Color(1f, 0.35f, 0.1f, 1f), "ColorIntentionalCombat");
		_snapShowCompass = MinimapPlugin.ShowCompass.Value;
		_snapCompassFontSize = MinimapPlugin.CompassFontSize.Value;
		_snapCompassNorthColor = MinimapPlugin.CompassNorthColor.Value;
		_snapCompassSouthColor = MinimapPlugin.CompassSouthColor.Value;
		_snapCompassEastColor = MinimapPlugin.CompassEastColor.Value;
		_snapCompassWestColor = MinimapPlugin.CompassWestColor.Value;
		_snapMinimapOpacity = MinimapPlugin.MinimapOpacity.Value;
	}

	public static CM_PageMap FindMapPage()
	{
		if ((Object)(object)_cachedMapPage != (Object)null && ((Il2CppObjectBase)_cachedMapPage).Pointer != IntPtr.Zero)
		{
			return _cachedMapPage;
		}
		GameObject val = GameObject.Find("CM_PageMap_CellUI(Clone)");
		if ((Object)(object)val == (Object)null)
		{
			val = GameObject.Find("CM_PageMap_CellUI");
		}
		if ((Object)(object)val != (Object)null)
		{
			CM_PageMap component = val.GetComponent<CM_PageMap>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
		}
		GameObject val2 = GameObject.Find("GUI");
		if ((Object)(object)val2 == (Object)null)
		{
			return null;
		}
		Transform val3 = val2.transform.Find("CellUI_Camera(Clone)");
		if ((Object)(object)val3 == (Object)null)
		{
			val3 = val2.transform.Find("CellUI_Camera");
		}
		if ((Object)(object)val3 == (Object)null)
		{
			return null;
		}
		Transform val4 = val3.Find("MainMenuLayer");
		if ((Object)(object)val4 == (Object)null)
		{
			return null;
		}
		for (int i = 0; i < val4.childCount; i++)
		{
			CM_PageMap component2 = ((Component)val4.GetChild(i)).GetComponent<CM_PageMap>();
			if ((Object)(object)component2 != (Object)null)
			{
				return component2;
			}
		}
		return null;
	}

	public static void InitFromMapPage(CM_PageMap mapPage)
	{
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Expected O, but got Unknown
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Expected O, but got Unknown
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Expected O, but got Unknown
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: 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_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043c: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mapPage == (Object)null || ((Il2CppObjectBase)mapPage).Pointer == IntPtr.Zero)
		{
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] mapPage pointer was zero — skipping."));
			return;
		}
		CacheHotConfig();
		OverlayCanvasManager.EnsureCreated();
		if ((Object)(object)OverlayCanvasManager.CanvasRoot == (Object)null || ((Il2CppObjectBase)OverlayCanvasManager.CanvasRoot).Pointer == IntPtr.Zero)
		{
			Debug.LogError(Object.op_Implicit("[MinimapMod] CanvasRoot unavailable."));
			return;
		}
		try
		{
			Cleanup();
			MapPageInstance = mapPage;
			_isFullMapOpen = false;
			Camera val = null;
			GameObject val2 = GameObject.Find("CellUI_Camera(Clone)");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = GameObject.Find("CellUI_Camera");
			}
			if ((Object)(object)val2 != (Object)null)
			{
				val = val2.GetComponent<Camera>();
			}
			if ((Object)(object)val == (Object)null)
			{
				foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras)
				{
					if (((Component)item).gameObject.layer == LayerMask.NameToLayer("UI") && (Object)(object)item.targetTexture != (Object)null)
					{
						val = item;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError(Object.op_Implicit("[MinimapMod] Could not find CellUI_Camera."));
				return;
			}
			MinimapPlugin.UILayer = LayerMask.NameToLayer("UI");
			Transform val3 = ((Component)mapPage).transform.Find("MapHolder");
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError(Object.op_Implicit("[MinimapMod] Could not find MapHolder."));
				return;
			}
			_mapHolderOriginalParent = val3.parent;
			_mapHolderOriginalLayer = ((Component)val3).gameObject.layer;
			_mapHolderInstance = ((Component)val3).gameObject;
			_mapMover = val3.Find("MapMover");
			_mapMoverElements = (((Object)(object)_mapMover != (Object)null) ? _mapMover.Find("MapMoverElements") : null);
			_localPlayerMapItem = null;
			if ((Object)(object)_mapMover == (Object)null)
			{
				Debug.LogWarning(Object.op_Implicit("[MinimapMod] MapMover not found — player centering disabled."));
			}
			else if ((Object)(object)_mapMoverElements == (Object)null)
			{
				Debug.LogWarning(Object.op_Implicit("[MinimapMod] MapMoverElements not found — player centering disabled."));
			}
			if ((Object)(object)_mapHolderHost == (Object)null)
			{
				_mapHolderHost = new GameObject("MinimapMapHolderHost");
				Object.DontDestroyOnLoad((Object)(object)_mapHolderHost);
			}
			val3.SetParent(_mapHolderHost.transform, true);
			_mapHolderHost.SetActive(true);
			_mapHolderAllObjects.Clear();
			CollectAllChildren(_mapHolderInstance, _mapHolderAllObjects);
			SetLayerFlat(31);
			int num = (((Object)(object)val.targetTexture != (Object)null) ? ((Texture)val.targetTexture).width : 1920);
			int num2 = (((Object)(object)val.targetTexture != (Object)null) ? ((Texture)val.targetTexture).height : 1080);
			_minimapRT = new RenderTexture(num, num2, 16);
			_minimapRT.Create();
			GameObject val4 = new GameObject("MinimapCamera");
			Object.DontDestroyOnLoad((Object)val4);
			val4.transform.position = ((Component)val).transform.position;
			val4.transform.rotation = ((Component)val).transform.rotation;
			_minimapCamera = ((Il2CppObjectBase)val4.AddComponent(Il2CppType.Of<Camera>())).Cast<Camera>();
			_minimapCamera.orthographic = val.orthographic;
			_minimapCamera.orthographicSize = val.orthographicSize;
			_minimapCamera.nearClipPlane = val.nearClipPlane;
			_minimapCamera.farClipPlane = val.farClipPlane;
			_minimapCamera.clearFlags = (CameraClearFlags)2;
			_minimapCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
			_minimapCamera.cullingMask = int.MinValue;
			_minimapCamera.targetTexture = _minimapRT;
			_minimapCamera.depth = val.depth + 1f;
			_minimapCamera.aspect = 1f;
			((Behaviour)_minimapCamera).enabled = true;
			_isCameraEnabledByPlayerLayer = true;
			BuildUI();
			_mapHolderInstance.transform.localScale = new Vector3(_minimapScale, _minimapScale, 1f);
			MapPageInstance.m_scaleCurrent = _minimapScale;
			if (_cfgDetectCombatState && (Object)(object)_locationLabel != (Object)null && ((Il2CppObjectBase)_locationLabel).Pointer != IntPtr.Zero)
			{
				DRAMA_State currentStateEnum = DramaManager.CurrentStateEnum;
				((Graphic)_locationLabel).color = GetDramaStateColor(currentStateEnum);
				_lastDramaState = currentStateEnum;
				_pendingDramaState = currentStateEnum;
				_pendingStateTime = -1f;
			}
			RefreshPanelVisibility();
		}
		catch (Exception value)
		{
			Debug.LogError(Object.op_Implicit($"[MinimapMod] Exception in InitFromMapPage: {value}"));
			Cleanup();
		}
	}

	public static void Cleanup()
	{
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_mapHolderInstance != (Object)null && ((Il2CppObjectBase)_mapHolderInstance).Pointer != IntPtr.Zero && (Object)(object)_mapHolderOriginalParent != (Object)null)
		{
			_mapHolderInstance.transform.SetParent(_mapHolderOriginalParent, true);
			if (_mapHolderAllObjects.Count > 0)
			{
				SetLayerFlat(_mapHolderOriginalLayer);
			}
			else
			{
				SetLayerRecursively(_mapHolderInstance, _mapHolderOriginalLayer);
			}
		}
		_mapHolderAllObjects.Clear();
		_cachedMapHolderChildCount = -1;
		_mapHolderInstance = null;
		_mapHolderOriginalParent = null;
		for (int i = 0; i < _mapSpriteRenderers.Count; i++)
		{
			SpriteRenderer val = _mapSpriteRenderers[i];
			Material val2 = _mapSpriteMats[i];
			Texture val3 = _gridTileOriginals[i];
			if ((Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer != IntPtr.Zero && (Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero && (Object)(object)val3 != (Object)null)
			{
				val2.SetTexture("_GridTile", val3);
			}
		}
		_mapSpriteMats.Clear();
		_mapSpriteRenderers.Clear();
		_gridTileOriginals.Clear();
		DestroyPlayerLines();
		_mapMover = null;
		_mapMoverElements = null;
		_localPlayerMapItem = null;
		_localPlayerAgent = null;
		_localPlayerLoco = null;
		_lastKnownDimension = (eDimensionIndex)(-1);
		_isInNonRealityDimension = false;
		_lastCompassY = float.NaN;
		MapPageInstance = null;
		_cachedMapPage = null;
		_isFullMapOpen = false;
		_isMenuLayerActive = false;
		_isCameraEnabledByPlayerLayer = false;
		_playerIconScaleApplied = false;
		_objectIconScaleApplied = false;
		if ((Object)(object)MinimapDisplay != (Object)null && ((Il2CppObjectBase)MinimapDisplay).Pointer != IntPtr.Zero)
		{
			RawImage component = MinimapDisplay.GetComponent<RawImage>();
			if ((Object)(object)component != (Object)null && ((Il2CppObjectBase)component).Pointer != IntPtr.Zero)
			{
				component.texture = null;
			}
		}
		_lastLabelText = null;
		_lastDramaState = (DRAMA_State)2;
		_pendingDramaState = (DRAMA_State)2;
		_pendingStateTime = -1f;
		_wasZoomHeld = false;
		_cachedZoomColor = null;
		_cachedBorderColor = null;
		if ((Object)(object)_minimapCamera != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)((Component)_minimapCamera).gameObject);
			_minimapCamera = null;
		}
		if ((Object)(object)_minimapRT != (Object)null)
		{
			_minimapRT.Release();
			_minimapRT = null;
		}
		if ((Object)(object)BackgroundPanel != (Object)null && ((Il2CppObjectBase)BackgroundPanel).Pointer != IntPtr.Zero)
		{
			BackgroundPanel.SetActive(false);
		}
		if ((Object)(object)_mapHolderHost != (Object)null && ((Il2CppObjectBase)_mapHolderHost).Pointer != IntPtr.Zero)
		{
			_mapHolderHost.SetActive(false);
		}
	}

	private static void BuildUI()
	{
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Expected O, but got Unknown
		//IL_020d: 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_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Expected O, but got Unknown
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d3: Expected O, but got Unknown
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_0478: Unknown result type (might be due to invalid IL or missing references)
		//IL_0483: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0321: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)BackgroundPanel != (Object)null && ((Il2CppObjectBase)BackgroundPanel).Pointer != IntPtr.Zero)
		{
			if ((Object)(object)MinimapDisplay != (Object)null && ((Il2CppObjectBase)MinimapDisplay).Pointer != IntPtr.Zero)
			{
				RawImage component = MinimapDisplay.GetComponent<RawImage>();
				if ((Object)(object)component != (Object)null && ((Il2CppObjectBase)component).Pointer != IntPtr.Zero)
				{
					component.texture = (Texture)(object)_minimapRT;
				}
			}
			if ((Object)(object)_locationLabel != (Object)null && ((Il2CppObjectBase)_locationLabel).Pointer != IntPtr.Zero)
			{
				((Component)_locationLabel).gameObject.SetActive(MinimapPlugin.ShowLocationLabel.Value);
			}
			if ((Object)(object)_compassRoot != (Object)null && ((Il2CppObjectBase)_compassRoot).Pointer != IntPtr.Zero)
			{
				_compassRoot.SetActive(MinimapPlugin.MapMatchPlayerRotation.Value && MinimapPlugin.ShowCompass.Value);
			}
			return;
		}
		string value = MinimapPlugin.MapShape.Value;
		float value2 = MinimapPlugin.MapScale.Value;
		float num;
		float num2 = (num = 1080f * value2);
		bool flag = !string.Equals(MinimapPlugin.AnchorX.Value, "Left", StringComparison.OrdinalIgnoreCase);
		bool num3 = string.Equals(MinimapPlugin.AnchorY.Value, "Top", StringComparison.OrdinalIgnoreCase);
		float num4 = (flag ? 1f : 0f);
		float num5 = (num3 ? 1f : 0f);
		float num6 = (flag ? (0f - MinimapPlugin.OffsetX.Value) : MinimapPlugin.OffsetX.Value);
		float num7 = (num3 ? (0f - MinimapPlugin.OffsetY.Value) : MinimapPlugin.OffsetY.Value);
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(num4, num5);
		Vector2 pivot = default(Vector2);
		((Vector2)(ref pivot))..ctor(num4, num5);
		Vector2 anchoredPosition = default(Vector2);
		((Vector2)(ref anchoredPosition))..ctor(num6, num7);
		BackgroundPanel = new GameObject("MinimapBackground");
		BackgroundPanel.transform.SetParent(OverlayCanvasManager.CanvasRoot.transform, false);
		RectTransform obj = ((Il2CppObjectBase)BackgroundPanel.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		obj.anchorMin = val;
		obj.anchorMax = val;
		obj.pivot = pivot;
		obj.anchoredPosition = anchoredPosition;
		obj.sizeDelta = new Vector2(num, num2);
		Transform transform = BackgroundPanel.transform;
		if (value == "Circle")
		{
			GameObject val2 = new GameObject("MinimapCircleMask");
			val2.transform.SetParent(BackgroundPanel.transform, false);
			RectTransform obj2 = ((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			obj2.sizeDelta = Vector2.zero;
			obj2.anchoredPosition = Vector2.zero;
			Image obj3 = ((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<Image>())).Cast<Image>();
			obj3.sprite = _circleSprite ?? (_circleSprite = CreateCircleSprite(256));
			((Graphic)obj3).color = Color.white;
			((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<Mask>())).Cast<Mask>().showMaskGraphic = false;
			GameObject val3 = new GameObject("MinimapCircleBackground");
			val3.transform.SetParent(val2.transform, false);
			RectTransform obj4 = ((Il2CppObjectBase)val3.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
			obj4.anchorMin = Vector2.zero;
			obj4.anchorMax = Vector2.one;
			obj4.sizeDelta = Vector2.zero;
			obj4.anchoredPosition = Vector2.zero;
			Image val4 = ((Il2CppObjectBase)val3.AddComponent(Il2CppType.Of<Image>())).Cast<Image>();
			((Graphic)val4).color = Color.clear;
			val3.transform.SetAsFirstSibling();
			transform = val2.transform;
			_backgroundGraphic = ((Il2CppObjectBase)val4).Cast<Graphic>();
		}
		else
		{
			Image obj5 = ((Il2CppObjectBase)BackgroundPanel.AddComponent(Il2CppType.Of<Image>())).Cast<Image>();
			((Graphic)obj5).color = Color.clear;
			_backgroundGraphic = ((Il2CppObjectBase)obj5).Cast<Graphic>();
		}
		MinimapDisplay = new GameObject("MinimapDisplay");
		MinimapDisplay.transform.SetParent(transform, false);
		RectTransform obj6 = ((Il2CppObjectBase)MinimapDisplay.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		obj6.anchorMin = Vector2.zero;
		obj6.anchorMax = Vector2.one;
		obj6.sizeDelta = Vector2.zero;
		obj6.anchoredPosition = Vector2.zero;
		((Il2CppObjectBase)MinimapDisplay.AddComponent(Il2CppType.Of<RawImage>())).Cast<RawImage>().texture = (Texture)(object)_minimapRT;
		BuildLocationLabel();
		GameObject val5 = new GameObject("MinimapBorder");
		val5.transform.SetParent(BackgroundPanel.transform, false);
		RectTransform obj7 = ((Il2CppObjectBase)val5.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		obj7.anchorMin = Vector2.zero;
		obj7.anchorMax = Vector2.one;
		obj7.sizeDelta = new Vector2(8f, 8f);
		obj7.anchoredPosition = Vector2.zero;
		Image val6 = ((Il2CppObjectBase)val5.AddComponent(Il2CppType.Of<Image>())).Cast<Image>();
		if (value == "Circle")
		{
			val6.sprite = _circleSprite ?? (_circleSprite = CreateCircleSprite(256));
		}
		((Graphic)val6).color = Color.clear;
		_borderGraphic = ((Il2CppObjectBase)val6).Cast<Graphic>();
		val5.transform.SetAsFirstSibling();
		if (MinimapPlugin.MapMatchPlayerRotation.Value)
		{
			BuildCompass();
		}
	}

	private static void BuildLocationLabel()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_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_00ff: 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)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: 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_016f: 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)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("MinimapLocationLabel");
		val.transform.SetParent(BackgroundPanel.transform, false);
		((Il2CppObjectBase)val.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		_locationLabel = ((Il2CppObjectBase)val.AddComponent(Il2CppType.Of<Text>())).Cast<Text>();
		string text = MinimapPlugin.LocationLabelFont.Value.Trim();
		string text2 = (text.EndsWith(".ttf", StringComparison.OrdinalIgnoreCase) ? text : (text + ".ttf"));
		Font builtinResource = Resources.GetBuiltinResource<Font>(text2);
		if ((Object)(object)builtinResource == (Object)null)
		{
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] Font '" + text2 + "' not found — falling back to Arial."));
			builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
		}
		_locationLabel.font = builtinResource;
		_locationLabel.fontSize = MinimapPlugin.LocationLabelFontSize.Value;
		_locationLabel.alignment = (TextAnchor)4;
		_locationLabel.text = "";
		ApplyLabelPosition(MinimapPlugin.LocationLabelPosition.Value);
		_lastDramaState = DramaManager.CurrentStateEnum;
		_pendingDramaState = _lastDramaState;
		_pendingStateTime = -1f;
		((Graphic)_locationLabel).color = (MinimapPlugin.DetectCombatState.Value ? GetDramaStateColor(_lastDramaState) : Color.white);
		float value = MinimapPlugin.LabelOutlineThickness.Value;
		Color effectColor = ParseColor(MinimapPlugin.LabelOutlineColor.Value, new Color(0f, 0f, 0f, 1f), "LabelOutlineColor");
		Outline obj = ((Il2CppObjectBase)val.AddComponent(Il2CppType.Of<Outline>())).Cast<Outline>();
		((Shadow)obj).effectColor = effectColor;
		((Shadow)obj).effectDistance = new Vector2(value, 0f - value);
		val.SetActive(MinimapPlugin.ShowLocationLabel.Value);
	}

	private static void ApplyLabelPosition(string position)
	{
		//IL_00db: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_locationLabel == (Object)null || ((Il2CppObjectBase)_locationLabel).Pointer == IntPtr.Zero)
		{
			return;
		}
		RectTransform val = ((Il2CppObjectBase)((Component)_locationLabel).gameObject.GetComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		if (!((Object)(object)val == (Object)null) && !(((Il2CppObjectBase)val).Pointer == IntPtr.Zero))
		{
			float num = (float)_locationLabel.fontSize + 8f;
			if (string.Equals(position, "Bottom", StringComparison.OrdinalIgnoreCase))
			{
				val.anchorMin = new Vector2(0f, 0f);
				val.anchorMax = new Vector2(1f, 0f);
				val.pivot = new Vector2(0.5f, 1f);
				val.anchoredPosition = new Vector2(0f, -6f);
			}
			else
			{
				val.anchorMin = new Vector2(0f, 1f);
				val.anchorMax = new Vector2(1f, 1f);
				val.pivot = new Vector2(0.5f, 0f);
				val.anchoredPosition = new Vector2(0f, 6f);
			}
			val.sizeDelta = new Vector2(0f, num);
		}
	}

	private static void BuildCompass()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_003e: 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_005e: 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_0073: 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_009e: 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_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: 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_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: 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)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		_compassRoot = new GameObject("CompassRoot");
		_compassRoot.transform.SetParent(BackgroundPanel.transform, false);
		RectTransform obj = ((Il2CppObjectBase)_compassRoot.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		obj.anchorMin = Vector2.zero;
		obj.anchorMax = Vector2.one;
		obj.pivot = new Vector2(0.5f, 0.5f);
		obj.sizeDelta = Vector2.zero;
		obj.anchoredPosition = Vector2.zero;
		RectTransform val = ((Il2CppObjectBase)BackgroundPanel.GetComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		_compassRadius = Mathf.Min(val.sizeDelta.x, val.sizeDelta.y) * 0.5f * 0.88f;
		Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
		int value = MinimapPlugin.CompassFontSize.Value;
		string[] array = new string[4] { "N", "S", "E", "W" };
		Color[] array2 = (Color[])(object)new Color[4]
		{
			ParseColor(MinimapPlugin.CompassNorthColor.Value, Color.white, "CompassNorthColor"),
			ParseColor(MinimapPlugin.CompassSouthColor.Value, Color.white, "CompassSouthColor"),
			ParseColor(MinimapPlugin.CompassEastColor.Value, Color.white, "CompassEastColor"),
			ParseColor(MinimapPlugin.CompassWestColor.Value, Color.white, "CompassWestColor")
		};
		_compassLabelRects = (RectTransform[])(object)new RectTransform[4];
		for (int i = 0; i < 4; i++)
		{
			GameObject val2 = new GameObject("CompassLabel_" + array[i]);
			val2.transform.SetParent(_compassRoot.transform, false);
			float num = (float)value * 1.8f;
			RectTransform val3 = ((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
			val3.anchorMin = new Vector2(0.5f, 0.5f);
			val3.anchorMax = new Vector2(0.5f, 0.5f);
			val3.pivot = new Vector2(0.5f, 0.5f);
			val3.sizeDelta = new Vector2(num, num);
			val3.anchoredPosition = Vector2.zero;
			Text obj2 = ((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<Text>())).Cast<Text>();
			obj2.text = array[i];
			((Graphic)obj2).color = array2[i];
			obj2.font = builtinResource;
			obj2.fontSize = value;
			obj2.fontStyle = (FontStyle)1;
			obj2.alignment = (TextAnchor)4;
			Outline obj3 = ((Il2CppObjectBase)val2.AddComponent(Il2CppType.Of<Outline>())).Cast<Outline>();
			((Shadow)obj3).effectColor = new Color(0f, 0f, 0f, 0.85f);
			((Shadow)obj3).effectDistance = new Vector2(2f, -2f);
			_compassLabelRects[i] = val3;
		}
		_compassRoot.SetActive(MinimapPlugin.ShowCompass.Value);
	}

	private static Sprite CreateCircleSprite(int size)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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)
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
		Color[] array = (Color[])(object)new Color[size * size];
		float num = (float)(size - 1) / 2f;
		float num2 = (float)size / 2f;
		float num3 = num2 * num2;
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num4 = (float)j - num;
				float num5 = (float)i - num;
				float num6 = num4 * num4 + num5 * num5;
				float num7 = ((num6 > num3) ? 0f : Mathf.Clamp01(num2 - Mathf.Sqrt(num6)));
				array[i * size + j] = new Color(1f, 1f, 1f, num7);
			}
		}
		val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f));
	}

	private static void ApplyPanelLayout()
	{
		//IL_0103: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: 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)
		if ((Object)(object)BackgroundPanel == (Object)null || ((Il2CppObjectBase)BackgroundPanel).Pointer == IntPtr.Zero)
		{
			return;
		}
		float value = MinimapPlugin.MapScale.Value;
		float num;
		float num2 = (num = 1080f * value);
		bool flag = !string.Equals(MinimapPlugin.AnchorX.Value, "Left", StringComparison.OrdinalIgnoreCase);
		bool num3 = string.Equals(MinimapPlugin.AnchorY.Value, "Top", StringComparison.OrdinalIgnoreCase);
		float num4 = (flag ? 1f : 0f);
		float num5 = (num3 ? 1f : 0f);
		float num6 = (flag ? (0f - MinimapPlugin.OffsetX.Value) : MinimapPlugin.OffsetX.Value);
		float num7 = (num3 ? (0f - MinimapPlugin.OffsetY.Value) : MinimapPlugin.OffsetY.Value);
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(num4, num5);
		RectTransform val2 = ((Il2CppObjectBase)BackgroundPanel.GetComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
		if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero)
		{
			val2.anchorMin = val;
			val2.anchorMax = val;
			val2.pivot = val;
			val2.anchoredPosition = new Vector2(num6, num7);
			val2.sizeDelta = new Vector2(num, num2);
			if ((Object)(object)_compassRoot != (Object)null && ((Il2CppObjectBase)_compassRoot).Pointer != IntPtr.Zero)
			{
				_compassRadius = Mathf.Min(num, num2) * 0.5f * 0.88f;
			}
		}
	}

	private static void RebuildPanel()
	{
		if ((Object)(object)BackgroundPanel != (Object)null && ((Il2CppObjectBase)BackgroundPanel).Pointer != IntPtr.Zero)
		{
			Object.Destroy((Object)(object)BackgroundPanel);
		}
		BackgroundPanel = null;
		MinimapDisplay = null;
		_backgroundGraphic = null;
		_borderGraphic = null;
		_locationLabel = null;
		_compassRoot = null;
		_compassLabelRects = null;
		_snapMapScale = MinimapPlugin.MapScale.Value;
		_snapAnchorX = MinimapPlugin.AnchorX.Value;
		_snapAnchorY = MinimapPlugin.AnchorY.Value;
		_snapOffsetX = MinimapPlugin.OffsetX.Value;
		_snapOffsetY = MinimapPlugin.OffsetY.Value;
		BuildUI();
		_playerIconScaleApplied = false;
		_objectIconScaleApplied = false;
		_lastLabelText = null;
		RefreshPanelVisibility();
	}

	private static bool CanToggle(bool gameStateReady)
	{
		if ((Object)(object)BackgroundPanel == (Object)null)
		{
			return false;
		}
		return _isCameraEnabledByPlayerLayer && !_isFullMapOpen && !_isMenuLayerActive && !_isInNonRealityDimension && gameStateReady;
	}

	private static bool ShouldShow()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		if (CanToggle((int)GameStateManager.CurrentStateName >= 8))
		{
			return _isVisible;
		}
		return false;
	}

	public static void CheckToggle(bool gameStateReady)
	{
		//IL_00c0: 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_008d: Invalid comparison between Unknown and I4
		if (!CanToggle(gameStateReady))
		{
			return;
		}
		if ((Object)(object)_localPlayerAgent != (Object)null && ((Il2CppObjectBase)_localPlayerAgent).Pointer != IntPtr.Zero)
		{
			if ((Object)(object)_localPlayerLoco == (Object)null || ((Il2CppObjectBase)_localPlayerLoco).Pointer == IntPtr.Zero)
			{
				_localPlayerLoco = ((Component)_localPlayerAgent).GetComponent<PlayerLocomotion>();
			}
			if ((Object)(object)_localPlayerLoco != (Object)null && ((Il2CppObjectBase)_localPlayerLoco).Pointer != IntPtr.Zero && (int)_localPlayerLoco.m_currentStateEnum == 9)
			{
				return;
			}
		}
		if ((!((Object)(object)_chatBoxActive != (Object)null) || !(((Il2CppObjectBase)_chatBoxActive).Pointer != IntPtr.Zero) || !_chatBoxActive.activeSelf) && Input.GetKeyDown(_cfgToggleKey))
		{
			_isVisible = !_isVisible;
			RefreshPanelVisibility();
		}
	}

	public static void UpdateZoomBackground()
	{
		//IL_0024: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_backgroundGraphic == (Object)null || ((Il2CppObjectBase)_backgroundGraphic).Pointer == IntPtr.Zero)
		{
			return;
		}
		bool key = Input.GetKey(_cfgZoomKey);
		if (key != _wasZoomHeld)
		{
			_wasZoomHeld = key;
			_backgroundGraphic.color = (key ? ParseZoomColor() : Color.clear);
			if ((Object)(object)_borderGraphic != (Object)null && ((Il2CppObjectBase)_borderGraphic).Pointer != IntPtr.Zero)
			{
				_borderGraphic.color = (key ? ParseBorderColor() : Color.clear);
			}
		}
	}

	public static void CenterOnLocalPlayer(bool forceMinimapUpdate)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0083: 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_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_00ec: 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_00f4: 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_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		if (_isFullMapOpen || (Object)(object)_mapMover == (Object)null || (Object)(object)_mapMoverElements == (Object)null)
		{
			return;
		}
		if ((Object)(object)_localPlayerMapItem == (Object)null || ((Il2CppObjectBase)_localPlayerMapItem).Pointer == IntPtr.Zero)
		{
			_localPlayerMapItem = FindLocalPlayerMapItem();
		}
		if ((Object)(object)_localPlayerMapItem == (Object)null)
		{
			return;
		}
		try
		{
			Vector3 localPosition = _localPlayerMapItem.localPosition;
			_mapMover.localPosition = new Vector3(0f - localPosition.x, 0f - localPosition.y, _mapMover.localPosition.z);
			if ((Object)(object)_localPlayerAgent == (Object)null || ((Il2CppObjectBase)_localPlayerAgent).Pointer == IntPtr.Zero)
			{
				_localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
			}
			PlayerAgent localPlayerAgent = _localPlayerAgent;
			if ((Object)(object)localPlayerAgent != (Object)null && ((Il2CppObjectBase)localPlayerAgent).Pointer != IntPtr.Zero)
			{
				eDimensionIndex dimensionIndex = ((Agent)localPlayerAgent).DimensionIndex;
				if (dimensionIndex != _lastKnownDimension)
				{
					_lastKnownDimension = dimensionIndex;
					SyncActiveDimension(dimensionIndex);
				}
			}
			if (!_cfgMatchRotation || !((Object)(object)localPlayerAgent != (Object)null) || !(((Il2CppObjectBase)localPlayerAgent).Pointer != IntPtr.Zero))
			{
				return;
			}
			float y = ((Component)localPlayerAgent).transform.eulerAngles.y;
			if (forceMinimapUpdate || !Mathf.Approximately(y, _lastCompassY))
			{
				_lastCompassY = y;
				if ((Object)(object)_mapHolderHost != (Object)null)
				{
					_mapHolderHost.transform.localEulerAngles = new Vector3(0f, 0f, y);
				}
				if ((Object)(object)_mapHolderInstance != (Object)null)
				{
					_mapHolderInstance.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
				}
				UpdateCompassPositions(y);
			}
		}
		catch (Exception ex)
		{
			_localPlayerMapItem = null;
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] CenterOnLocalPlayer failed: " + ex.Message));
		}
	}

	private static Transform FindLocalPlayerMapItem()
	{
		if ((Object)(object)_mapMoverElements == (Object)null)
		{
			return null;
		}
		for (int i = 0; i < _mapMoverElements.childCount; i++)
		{
			Transform child = _mapMoverElements.GetChild(i);
			if (!((Object)(object)child == (Object)null) && !(((Object)child).name != "CM_MapSyncPlayerGUIItem(Clone)"))
			{
				Transform val = child.Find("localPlayer");
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
				{
					return child;
				}
			}
		}
		return null;
	}

	private static void SyncActiveDimension(eDimensionIndex dim)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		bool flag = (int)dim > 0;
		if (!MinimapPlugin.DimensionMapsInstalled)
		{
			if (flag != _isInNonRealityDimension)
			{
				_isInNonRealityDimension = flag;
				RefreshPanelVisibility();
			}
			return;
		}
		_isInNonRealityDimension = false;
		if ((Object)(object)_mapMover == (Object)null)
		{
			return;
		}
		try
		{
			string text = ((object)(eDimensionIndex)(ref dim)).ToString();
			string value = "_" + text;
			for (int i = 0; i < _mapMover.childCount; i++)
			{
				Transform child = _mapMover.GetChild(i);
				if (!((Object)(object)child == (Object)null))
				{
					string name = ((Object)child).name;
					if (name.StartsWith("MapDetailsUI(Clone)_"))
					{
						((Component)child).gameObject.SetActive(name.EndsWith(value));
					}
					else if (IsDimensionRootName(name))
					{
						((Component)child).gameObject.SetActive(name == text);
					}
				}
			}
		}
		catch (Exception ex)
		{
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] SyncActiveDimension failed: " + ex.Message));
		}
	}

	private static bool IsDimensionRootName(string name)
	{
		if (name == "Reality")
		{
			return true;
		}
		if (name.StartsWith("Dimension_") && name.Length > "Dimension_".Length)
		{
			return true;
		}
		return false;
	}

	private static void UpdateCompassPositions(float playerY)
	{
		//IL_0053: 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_0082: 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)
		if (!((Object)(object)_compassRoot == (Object)null) && !(((Il2CppObjectBase)_compassRoot).Pointer == IntPtr.Zero) && _compassLabelRects != null)
		{
			float num = (float)Math.PI / 180f * playerY;
			float num2 = Mathf.Cos(num);
			float num3 = Mathf.Sin(num);
			float compassRadius = _compassRadius;
			_compassLabelRects[0].anchoredPosition = new Vector2((0f - compassRadius) * num3, compassRadius * num2);
			_compassLabelRects[1].anchoredPosition = new Vector2(compassRadius * num3, (0f - compassRadius) * num2);
			_compassLabelRects[2].anchoredPosition = new Vector2(compassRadius * num2, compassRadius * num3);
			_compassLabelRects[3].anchoredPosition = new Vector2((0f - compassRadius) * num2, (0f - compassRadius) * num3);
		}
	}

	public static void UpdateLocationLabel()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0065: 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_006d: 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)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_locationLabel == (Object)null || ((Il2CppObjectBase)_locationLabel).Pointer == IntPtr.Zero || !_cfgShowLocationLabel)
		{
			return;
		}
		string cachedLabel = ZoneAreaTracker.CachedLabel;
		if (cachedLabel != _lastLabelText)
		{
			_lastLabelText = cachedLabel;
			_locationLabel.text = cachedLabel;
		}
		if (!_cfgDetectCombatState)
		{
			return;
		}
		DRAMA_State currentStateEnum = DramaManager.CurrentStateEnum;
		if (currentStateEnum != _lastDramaState)
		{
			if (currentStateEnum != _pendingDramaState)
			{
				_pendingDramaState = currentStateEnum;
				_pendingStateTime = Time.time;
			}
			else if (Time.time - _pendingStateTime >= 2f)
			{
				_lastDramaState = _pendingDramaState;
				((Graphic)_locationLabel).color = GetDramaStateColor(_lastDramaState);
			}
		}
	}

	private static Color GetDramaStateColor(DRAMA_State state)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected I4, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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)
		//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)
		switch ((int)state)
		{
		case 0:
			return _cachedColorElevatorIdle;
		case 1:
			return _cachedColorElevatorGoingDown;
		case 2:
		case 3:
		case 4:
			return _cachedColorUndetected;
		case 5:
			return _cachedColorEncounter;
		case 6:
			return _cachedColorCombat;
		case 7:
			return _cachedColorSurvival;
		case 8:
			return _cachedColorIntentionalCombat;
		default:
			return _cachedColorDramaDefault;
		}
	}

	public static void UpdatePlayerLines()
	{
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Expected O, but got Unknown
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_040b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: 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_01fc: Expected O, but got Unknown
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		if (_cfgPlayerLineThickness <= 0)
		{
			if (_playerLineObjects.Count > 0)
			{
				DestroyPlayerLines();
			}
		}
		else
		{
			if (!_isCameraEnabledByPlayerLayer || _isFullMapOpen || (Object)(object)_mapMoverElements == (Object)null || (Object)(object)_localPlayerMapItem == (Object)null || ((Il2CppObjectBase)_localPlayerMapItem).Pointer == IntPtr.Zero)
			{
				return;
			}
			int num = _playerLineObjects.Count;
			if (Time.time >= _playerCountNextCheckTime)
			{
				num = 0;
				for (int i = 0; i < _mapMoverElements.childCount; i++)
				{
					Transform child = _mapMoverElements.GetChild(i);
					if (!((Object)(object)child == (Object)null) && !((Object)(object)child == (Object)(object)_localPlayerMapItem) && !(((Object)child).name != "CM_MapSyncPlayerGUIItem(Clone)") && ((Component)child).gameObject.activeSelf)
					{
						Transform val = child.Find("syncPlayer");
						if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
						{
							num++;
						}
					}
				}
				_playerCountNextCheckTime = Time.time + 1f;
			}
			if (_playerLineObjects.Count != num)
			{
				_playerCountNextCheckTime = 0f;
				DestroyPlayerLines();
				float num2 = _cfgPlayerLineThickness;
				if (_spriteDefaultShader == null)
				{
					_spriteDefaultShader = Shader.Find("Sprites/Default");
				}
				Material material = new Material(_spriteDefaultShader);
				for (int j = 0; j < _mapMoverElements.childCount; j++)
				{
					Transform child2 = _mapMoverElements.GetChild(j);
					if ((Object)(object)child2 == (Object)null || (Object)(object)child2 == (Object)(object)_localPlayerMapItem || ((Object)child2).name != "CM_MapSyncPlayerGUIItem(Clone)")
					{
						continue;
					}
					Transform val2 = child2.Find("syncPlayer");
					if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeSelf)
					{
						continue;
					}
					GameObject val3 = new GameObject($"MinimapPlayerLine_{_playerLineObjects.Count}");
					val3.layer = 31;
					if ((Object)(object)_mapHolderHost != (Object)null)
					{
						val3.transform.SetParent(_mapHolderHost.transform, false);
					}
					LineRenderer val4 = ((Il2CppObjectBase)val3.AddComponent(Il2CppType.Of<LineRenderer>())).Cast<LineRenderer>();
					val4.positionCount = 2;
					val4.useWorldSpace = true;
					val4.startWidth = num2;
					val4.endWidth = num2;
					((Renderer)val4).material = material;
					Color val5 = Color.white;
					Image componentInChildren = ((Component)child2).GetComponentInChildren<Image>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						val5 = ((Graphic)componentInChildren).color;
					}
					else
					{
						SpriteRenderer componentInChildren2 = ((Component)child2).GetComponentInChildren<SpriteRenderer>();
						if ((Object)(object)componentInChildren2 != (Object)null)
						{
							val5 = componentInChildren2.color;
						}
					}
					val4.startColor = val5;
					val4.endColor = val5;
					_playerLineObjects.Add(val3);
					_cachedPlayerItems.Add(child2);
					_cachedLineRenderers.Add(val4);
					if (_playerLineInsertionIndex < 0)
					{
						_playerLineInsertionIndex = _mapHolderAllObjects.Count;
					}
					_mapHolderAllObjects.Add(val3);
				}
			}
			Vector3 position = _localPlayerMapItem.position;
			for (int k = 0; k < _cachedLineRenderers.Count; k++)
			{
				Transform val6 = _cachedPlayerItems[k];
				LineRenderer val7 = _cachedLineRenderers[k];
				if ((Object)(object)val7 == (Object)null)
				{
					continue;
				}
				bool flag = (Object)(object)val6 != (Object)null && ((Il2CppObjectBase)val6).Pointer != IntPtr.Zero && ((Component)val6).gameObject.activeSelf;
				if (!((Renderer)val7).enabled && flag)
				{
					Color val8 = Color.white;
					Image componentInChildren3 = ((Component)val6).GetComponentInChildren<Image>();
					if ((Object)(object)componentInChildren3 != (Object)null)
					{
						val8 = ((Graphic)componentInChildren3).color;
					}
					else
					{
						SpriteRenderer componentInChildren4 = ((Component)val6).GetComponentInChildren<SpriteRenderer>();
						if ((Object)(object)componentInChildren4 != (Object)null)
						{
							val8 = componentInChildren4.color;
						}
					}
					val7.startColor = val8;
					val7.endColor = val8;
					((Renderer)val7).enabled = true;
				}
				else if (((Renderer)val7).enabled != flag)
				{
					((Renderer)val7).enabled = flag;
				}
				if (flag)
				{
					val7.SetPosition(0, val6.position);
					val7.SetPosition(1, position);
				}
			}
		}
	}

	public static void TickMapUpdate()
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)MapPageInstance == (Object)null || (Object)(object)_minimapCamera == (Object)null || !_isCameraEnabledByPlayerLayer)
		{
			return;
		}
		IsTickingUpdate = true;
		try
		{
			((CM_PageBase)MapPageInstance).Update();
		}
		catch (Exception ex)
		{
			Debug.LogWarning(Object.op_Implicit("[MinimapMod] Map tick failed: " + ex.Message));
		}
		finally
		{
			IsTickingUpdate = false;
		}
		if (!_isFullMapOpen && (Object)(object)_mapHolderInstance != (Object)null && ((Il2CppObjectBase)_mapHolderInstance).Pointer != IntPtr.Zero)
		{
			_minimapScale = _mapHolderInstance.transform.localScale.x;
		}
		if ((Object)(object)_mapHolderInstance != (Object)null && !_isFullMapOpen)
		{
			int childCount = _mapHolderInstance.transform.childCount;
			if (childCount != _cachedMapHolderChildCount)
			{
				_cachedMapHolderChildCount = childCount;
				_mapHolderAllObjects.Clear();
				CollectAllChildren(_mapHolderInstance, _mapHolderAllObjects);
				SetLayerFlat(31);
				PatchMapSpriteMaterial();
			}
		}
		if (!_playerIconScaleApplied && (Object)(object)_mapMoverElements != (Object)null && !_isFullMapOpen)
		{
			for (int i = 0; i < _mapMoverElements.childCount; i++)
			{
				Transform child = _mapMoverElements.GetChild(i);
				if ((Object)(object)child != (Object)null && ((Object)child).name == "CM_MapSyncPlayerGUIItem(Clone)")
				{
					ApplyPlayerIconScale();
					_playerIconScaleApplied = true;
					break;
				}
			}
		}
		if (_objectIconScaleApplied || !((Object)(object)_mapMover != (Object)null) || _isFullMapOpen)
		{
			return;
		}
		bool flag = false;
		for (int j = 0; j < _mapMover.childCount; j++)
		{
			if (flag)
			{
				break;
			}
			Transform child2 = _mapMover.GetChild(j);
			if ((Object)(object)child2 == (Object)null)
			{
				continue;
			}
			for (int k = 0; k < child2.childCount; k++)
			{
				if (flag)
				{
					break;
				}
				Transform child3 = child2.GetChild(k);
				if ((Object)(object)child3 == (Object)null || !((Object)child3).name.StartsWith("CM_MapZoneGUIItem"))
				{
					continue;
				}
				Transform val = child3.Find("AreaRoot");
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				for (int l = 0; l < val.childCount; l++)
				{
					if (flag)
					{
						break;
					}
					Transform child4 = val.GetChild(l);
					if (!((Object)(object)child4 == (Object)null) && ((Object)child4).name.StartsWith("CM_MapAreaGUIItem"))
					{
						Transform val2 = child4.Find("GUIObjRoot");
						if ((Object)(object)val2 != (Object)null && val2.childCount > 0)
						{
							flag = true;
						}
					}
				}
			}
		}
		if (flag)
		{
			ApplyObjectIconScale();
			_objectIconScaleApplied = true;
		}
	}

	public static void OnFullMapOpened()
	{
		//IL_003d: 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)
		if (IsTickingUpdate)
		{
			return;
		}
		_isFullMapOpen = true;
		if ((Object)(object)_mapHolderHost != (Object)null)
		{
			_mapHolderHost.SetActive(true);
		}
		if ((Object)(object)_mapHolderHost != (Object)null)
		{
			_mapHolderHost.transform.localEulerAngles = Vector3.zero;
		}
		if ((Object)(object)_mapHolderInstance != (Object)null)
		{
			SetLayerFlat(MinimapPlugin.UILayer);
		}
		RestorePlayerIconScale();
		RestoreObjectIconScale();
		SetGridVisible(visible: true);
		if ((Object)(object)BackgroundPanel != (Object)null)
		{
			BackgroundPanel.SetActive(false);
		}
		if ((Object)(object)_mapHolderInstance != (Object)null)
		{
			_mapHolderInstance.transform.localScale = new Vector3(_fullmapScale, _fullmapScale, 1f);
			if ((Object)(object)MapPageInstance != (Object)null)
			{
				MapPageInstance.m_scaleCurrent = _fullmapScale;
			}
		}
	}

	public static void OnFullMapClosed()
	{
		//IL_004e: 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)
		if (IsTickingUpdate)
		{
			return;
		}
		_isFullMapOpen = false;
		if ((Object)(object)_mapHolderInstance != (Object)null)
		{
			SetLayerFlat(31);
		}
		ApplyPlayerIconScale();
		ApplyObjectIconScale();
		SetGridVisible(visible: false);
		RefreshPanelVisibility();
		if ((Object)(object)_mapHolderInstance != (Object)null)
		{
			_fullmapScale = _mapHolderInstance.transform.localScale.x;
			_mapHolderInstance.transform.localScale = new Vector3(_minimapScale, _minimapScale, 1f);
			if ((Object)(object)MapPageInstance != (Object)null)
			{
				MapPageInstance.m_scaleCurrent = _minimapScale;
			}
		}
	}

	public static void OnPlayerLayerStateChanged(bool playerLayerActive)
	{
		if (!((Object)(object)_minimapCamera == (Object)null))
		{
			_isCameraEnabledByPlayerLayer = playerLayerActive;
			((Behaviour)_minimapCamera).enabled = playerLayerActive;
			RefreshPanelVisibility();
		}
	}

	public static void OnMenuLayerStateChanged(bool menuLayerActive)
	{
		_isMenuLayerActive = menuLayerActive;
		RefreshPanelVisibility();
	}

	public static void SetMinimapCameraForTick(bool enable)
	{
		if (!((Object)(object)_minimapCamera == (Object)null))
		{
			if (enable && !((Behaviour)_minimapCamera).enabled)
			{
				((Behaviour)_minimapCamera).enabled = _isCameraEnabledByPlayerLayer;
			}
			else if (!enable && _isCameraEnabledByPlayerLayer)
			{
				((Behaviour)_minimapCamera).enabled = false;
			}
		}
	}

	private static void RefreshPanelVisibility()
	{
		if ((Object)(object)BackgroundPanel == (Object)null)
		{
			return;
		}
		bool flag = ShouldShow();
		BackgroundPanel.SetActive(flag);
		if ((Object)(object)_mapHolderHost != (Object)null)
		{
			_mapHolderHost.SetActive(flag || _isFullMapOpen);
		}
		foreach (GameObject playerLineObject in _playerLineObjects)
		{
			if ((Object)(object)playerLineObject != (Object)null && ((Il2CppObjectBase)playerLineObject).Pointer != IntPtr.Zero)
			{
				playerLineObject.SetActive(flag);
			}
		}
		if ((Object)(object)_locationLabel != (Object)null && ((Il2CppObjectBase)_locationLabel).Pointer != IntPtr.Zero)
		{
			((Component)_locationLabel).gameObject.SetActive(flag && _cfgShowLocationLabel);
		}
		if ((Object)(object)_compassRoot != (Object)null && ((Il2CppObjectBase)_compassRoot).Pointer != IntPtr.Zero)
		{
			_compassRoot.SetActive(flag && _cfgMatchRotation && _cfgShowCompass);
		}
	}

	private static void SetLayerFlat(int layer)
	{
		foreach (GameObject mapHolderAllObject in _mapHolderAllObjects)
		{
			if ((Object)(object)mapHolderAllObject != (Object)null)
			{
				mapHolderAllObject.layer = layer;
			}
		}
	}

	private static void CollectAllChildren(GameObject go, List<GameObject> result)
	{
		if (!((Object)(object)go == (Object)null))
		{
			result.Add(go);
			for (int i = 0; i < go.transform.childCount; i++)
			{
				CollectAllChildren(((Component)go.transform.GetChild(i)).gameObject, result);
			}
		}
	}

	private static void SetLayerRecursively(GameObject go, int layer)
	{
		if (!((Object)(object)go == (Object)null))
		{
			go.layer = layer;
			for (int i = 0; i < go.transform.childCount; i++)
			{
				SetLayerRecursively(((Component)go.transform.GetChild(i)).gameObject, layer);
			}
		}
	}

	private static void PatchMapSpriteMaterial()
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		try
		{
			foreach (Transform componentsInChild in _mapHolderInstance.GetComponentsInChildren<Transform>(true))
			{
				if (((Object)componentsInChild).name != "MapSprite")
				{
					continue;
				}
				SpriteRenderer component = ((Component)componentsInChild).GetComponent<SpriteRenderer>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				bool flag = false;
				for (int i = 0; i < _mapSpriteRenderers.Count; i++)
				{
					if ((Object)(object)_mapSpriteRenderers[i] != (Object)null && ((Il2CppObjectBase)_mapSpriteRenderers[i]).Pointer == ((Il2CppObjectBase)component).Pointer)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					Texture texture = ((Renderer)component).sharedMaterial.GetTexture("_GridTile");
					Material val2 = (((Renderer)component).sharedMaterial = new Material(((Renderer)component).sharedMaterial));
					_mapSpriteRenderers.Add(component);
					_mapSpriteMats.Add(val2);
					_gridTileOriginals.Add(texture);
					DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(69, 4);
					defaultInterpolatedStringHandler.AppendLiteral("[Minimap] Instanced MapSprite material '");
					defaultInterpolatedStringHandler.AppendFormatted(((Object)val2).name);
					defaultInterpolatedStringHandler.AppendLiteral("' ");
					defaultInterpolatedStringHandler.AppendLiteral("(#");
					defaultInterpolatedStringHandler.AppendFormatted(_mapSpriteRenderers.Count);
					defaultInterpolatedStringHandler.AppendLiteral(", parent: ");
					Transform parent = componentsInChild.parent;
					defaultInterpolatedStringHandler.AppendFormatted(((parent != null) ? ((Object)parent).name : null) ?? "?");
					defaultInterpolatedStringHandler.AppendLiteral("). ");
					defaultInterpolatedStringHandler.AppendLiteral("_GridTile = ");
					defaultInterpolatedStringHandler.AppendFormatted(((Object)(object)texture != (Object)null) ? ((Object)texture).name : "null");
					Debug.Log(Object.op_Implicit(defaultInterpolatedStringHandler.ToStringAndClear()));
				}
			}
			if (_mapSpriteRenderers.Count != 0)
			{
				SetGridVisible(visible: false);
			}
		}
		catch (Exception ex)
		{
			Debug.LogWarning(Object.op_Implicit("[Minimap] PatchMapSpriteMaterial failed: " + ex.Message));
		}
	}

	private static void SetGridVisible(bool visible)
	{
		if (_mapSpriteMats.Count == 0)
		{
			return;
		}
		for (int i = 0; i < _mapSpriteMats.Count; i++)
		{
			Material val = _mapSpriteMats[i];
			if (!((Object)(object)val == (Object)null) && !(((Il2CppObjectBase)val).Pointer == IntPtr.Zero))
			{
				val.SetTexture("_GridTile", (Texture)(visible ? ((object)_gridTileOriginals[i]) : ((object)_blankGridTile)));
			}
		}
	}

	private static void SetPlayerIconScale(float mult)
	{
		//IL_000e: 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_0019: 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)
		if ((Object)(object)_mapMoverElements == (Object)null)
		{
			return;
		}
		Vector3 localScale = Vector3.one * mult;
		for (int i = 0; i < _mapMoverElements.childCount; i++)
		{
			Transform child = _mapMoverElements.GetChild(i);
			if (!((Object)(object)child == (Object)null) && !(((Object)child).name != "CM_MapSyncPlayerGUIItem(Clone)"))
			{
				child.localScale = localScale;
			}
		}
	}

	public static void ApplyPlayerIconScale()
	{
		SetPlayerIconScale(MinimapPlugin.PlayerIconScale.Value);
	}

	public static void RestorePlayerIconScale()
	{
		SetPlayerIconScale(1f);
	}

	private static void SetObjectIconScale(float mult)
	{
		//IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_mapMover == (Object)null)
		{
			return;
		}
		Vector3 localScale = Vector3.one * mult;
		for (int i = 0; i < _mapMover.childCount; i++)
		{
			Transform child = _mapMover.GetChild(i);
			if ((Object)(object)child == (Object)null)
			{
				continue;
			}
			for (int j = 0; j < child.childCount; j++)
			{
				Transform child2 = child.GetChild(j);
				if ((Object)(object)child2 == (Object)null || !((Object)child2).name.StartsWith("CM_MapZoneGUIItem"))
				{
					continue;
				}
				Transform val = child2.Find("AreaRoot");
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				for (int k = 0; k < val.childCount; k++)
				{
					Transform child3 = val.GetChild(k);
					if ((Object)(object)child3 == (Object)null || !((Object)child3).name.StartsWith("CM_MapAreaGUIItem"))
					{
						continue;
					}
					Transform val2 = child3.Find("GUIObjRoot");
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					for (int l = 0; l < val2.childCount; l++)
					{
						Transform child4 = val2.GetChild(l);
						if (!((Object)(object)child4 == (Object)null) && !((Object)child4).name.StartsWith("CM_MapSign"))
						{
							child4.localScale = localScale;
						}
					}
				}
			}
		}
	}

	public static void ApplyObjectIconScale()
	{
		SetObjectIconScale(MinimapPlugin.MinimapObjectIconScale.Value);
	}

	public static void RestoreObjectIconScale()
	{
		SetObjectIconScale(1f);
	}

	public static void DestroyPlayerLines()
	{
		foreach (GameObject playerLineObject in _playerLineObjects)
		{
			if ((Object)(object)playerLineObject != (Object)null && ((Il2CppObjectBase)playerLineObject).Pointer != IntPtr.Zero)
			{
				Object.Destroy((Object)(object)playerLineObject);
			}
		}
		if (_playerLineInsertionIndex >= 0 && _playerLineInsertionIndex < _mapHolderAllObjects.Count)
		{
			_mapHolderAllObjects.RemoveRange(_playerLineInsertionIndex, _mapHolderAllObjects.Count - _playerLineInsertionIndex);
		}
		_playerLineInsertionIndex = -1;
		_playerLineObjects.Clear();
		_cachedPlayerItems.Clear();
		_cachedLineRenderers.Clear();
		_playerCountNextCheckTime = 0f;
	}

	private static void ApplyCompassFontSize(int fontSize)
	{
		//IL_005e: 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)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		if (_compassLabelRects == null || (Object)(object)_compassRoot == (Object)null || ((Il2CppObjectBase)_compassRoot).Pointer == IntPtr.Zero)
		{
			return;
		}
		for (int i = 0; i < _compassLabelRects.Length; i++)
		{
			RectTransform val = _compassLabelRects[i];
			if (!((Object)(object)val == (Object)null) && !(((Il2CppObjectBase)val).Pointer == IntPtr.Zero))
			{
				float num = (float)fontSize * 1.8f;
				val.sizeDelta = new Vector2(num, num);
				Component component = ((Component)val).gameObject.GetComponent(Il2CppType.Of<Text>());
				Text val2 = ((component != null) ? ((Il2CppObjectBase)component).Cast<Text>() : null);
				if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero)
				{
					val2.fontSize = fontSize;
				}
			}
		}
		if ((Object)(object)BackgroundPanel != (Object)null && ((Il2CppObjectBase)BackgroundPanel).Pointer != IntPtr.Zero)
		{
			RectTransform val3 = ((Il2CppObjectBase)BackgroundPanel.GetComponent(Il2CppType.Of<RectTransform>())).Cast<RectTransform>();
			if ((Object)(object)val3 != (Object)null && ((Il2CppObjectBase)val3).Pointer != IntPtr.Zero)
			{
				_compassRadius = Mathf.Min(val3.sizeDelta.x, val3.sizeDelta.y) * 0.5f * 0.88f;
			}
		}
	}

	private static void ApplyCompassColors()
	{
		//IL_003d: 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_004c: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		if (_compassLabelRects == null || (Object)(object)_compassRoot == (Object)null || ((Il2CppObjectBase)_compassRoot).Pointer == IntPtr.Zero)
		{
			return;
		}
		Color[] array = (Color[])(object)new Color[4]
		{
			ParseColor(MinimapPlugin.CompassNorthColor.Value, Color.white, "CompassNorthColor"),
			ParseColor(MinimapPlugin.CompassSouthColor.Value, Color.white, "CompassSouthColor"),
			ParseColor(MinimapPlugin.CompassEastColor.Value, Color.white, "CompassEastColor"),
			ParseColor(MinimapPlugin.CompassWestColor.Value, Color.white, "CompassWestColor")
		};
		for (int i = 0; i < _compassLabelRects.Length; i++)
		{
			RectTransform val = _compassLabelRects[i];
			if (!((Object)(object)val == (Object)null) && !(((Il2CppObjectBase)val).Pointer == IntPtr.Zero))
			{
				Component component = ((Component)val).gameObject.GetComponent(Il2CppType.Of<Text>());
				Text val2 = ((component != null) ? ((Il2CppObjectBase)component).Cast<Text>() : null);
				if ((Object)(object)val2 != (Object)null && ((Il2CppObjectBase)val2).Pointer != IntPtr.Zero)
				{
					((Graphic)val2).color = array[i];
				}
			}
		}
	}

	private static Color ParseColor(string raw, Color fallback, string configName = "")
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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)
		try
		{
			string text = raw.Trim();
			if (text.StartsWith("#") && text.Length == 7)
			{
				int num = Convert.ToInt32(text.Substring(1, 2), 16);
				int num2 = Convert.ToInt32(text.Substring(3, 2), 16);
				int num3 = Convert.ToInt32(text.Substring(5, 2), 16);
				return new Color((float)num / 255f, (float)num2 / 255f, (float)num3 / 255f, 1f);
			}
			string[] array = text.Split(' ');
			if (array.Length == 4 && float.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2) && float.TryParse(array[2], out var result3) && float.TryParse(array[3], out var result4))
			{
				return new Color(result, result2, result3, result4);
			}
		}
		catch
		{
		}
		string text2 = (string.IsNullOrEmpty(configName) ? raw : configName);
		Debug.LogWarning(Object.op_Implicit("[MinimapMod] Color parse failed for '" + text2 + "' — using fallback."));
		return fallback;
	}

	private static Color ParseZoomColor()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_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_0045: Unknown result type (might be due to invalid IL or missing references)
		Color valueOrDefault = _cachedZoomColor.GetValueOrDefault();
		if (!_cachedZoomColor.HasValue)
		{
			valueOrDefault = ParseColor(MinimapPlugin.MapBackgroundZoomColor.Value, new Color(1f, 0.6f, 0.2f, 1f), "MapBackgroundZoomColor");
			_cachedZoomColor = valueOrDefault;
		}
		return _cachedZoomColor.Value;
	}

	private static Color ParseBorderColor()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!_cachedBorderColor.HasValue)
		{
			Color val = ParseZoomColor();
			_cachedBorderColor = new Color(val.r, Mathf.Min(val.g + 0.15f, 1f), val.b, val.a);
		}
		return _cachedBorderColor.Value;
	}

	private static void ApplyMinimapOpacity(float opacity)
	{
		CanvasGroup canvasGroup = OverlayCanvasManager.CanvasGroup;
		if (!((Object)(object)canvasGroup == (Object)null) && !(((Il2CppObjectBase)canvasGroup).Pointer == IntPtr.Zero))
		{
			canvasGroup.alpha = opacity;
		}
	}

	public static void LiveConfigTick()
	{
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid I