Decompiled source of DungeonMapIcons v1.0.5

DungeonMapIcons.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DungeonMapIcons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DungeonMapIcons")]
[assembly: AssemblyTitle("DungeonMapIcons")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DungeonMapIcons
{
	[BepInPlugin("DungeonMapIcons", "Dungeon Map Icons", "1.0.5")]
	[BepInProcess("valheim.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "DungeonMapIcons";

		public const string PluginName = "Dungeon Map Icons";

		public const string PluginVersion = "1.0.5";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> DetectionRadius;

		internal static ConfigEntry<float> ScanInterval;

		internal static ConfigEntry<float> DuplicateRadius;

		internal static ConfigEntry<bool> AlwaysShowDungeonNames;

		internal static ConfigEntry<float> CustomIconScale;

		internal static ConfigEntry<IconStyle> SelectedIconStyle;

		internal static readonly Dictionary<string, Sprite> DefaultSprites = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		internal static readonly Dictionary<string, Sprite> EnhancedSprites = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		internal static readonly Dictionary<string, DungeonDefinition> ByLabel = new Dictionary<string, DungeonDefinition>(StringComparer.OrdinalIgnoreCase);

		private Harmony _harmony;

		private float _nextScan;

		private static readonly DungeonDefinition[] Dungeons = new DungeonDefinition[12]
		{
			new DungeonDefinition("Burial Chambers", "Default_Surtling core", "Enhanced_Surtling core", new string[4] { "Crypt2", "Crypt3", "Crypt4", "HalfBurried_ForestCrypt" }),
			new DungeonDefinition("Smouldering Tomb", "Default_Surtling trophy", "Enhanced_Surtling trophy", new string[1] { "Hildir_crypt" }),
			new DungeonDefinition("Troll Cave", "Default_Troll Trophy", "Enhanced_Troll Trophy", new string[2] { "TrollCave", "TrollCave02" }),
			new DungeonDefinition("Sunken Crypt", "Default_Swamp Key", "Enhanced_Swamp Key", new string[4] { "SunkenCrypt1", "SunkenCrypt2", "SunkenCrypt3", "SunkenCrypt4" }),
			new DungeonDefinition("Frost Cave", "Default_Drake Trophy", "Enhanced_Drake Trophy", new string[2] { "MountainCave01", "MountainCave02" }),
			new DungeonDefinition("Howling Cavern", "Default_Stone Golem Trophy", "Enhanced_Stone Golem Trophy", new string[1] { "Hildir_cave" }),
			new DungeonDefinition("Sealed Tower", "Default_Fuling totem", "Enhanced_Fuling totem", new string[1] { "Hildir_plainsfortress" }),
			new DungeonDefinition("Infested Mine", "Default_Black core", "Enhanced_Black core", new string[2] { "Mistlands_DvergrTownEntrance1", "Mistlands_DvergrTownEntrance2" }),
			new DungeonDefinition("Putrid Hole", "Default_Bloodstone", "Enhanced_Bloodstone", new string[3] { "MorgenHole1", "MorgenHole2", "MorgenHole3" }),
			new DungeonDefinition("Surtling geyser", "Shared_Surtling geyser", "Shared_Surtling geyser", new string[1] { "FireHole" }),
			new DungeonDefinition("Winding Tunnels", "Shared_Winding Tunnels", "Shared_Winding Tunnels", new string[1] { "TheHole01" }),
			new DungeonDefinition("Mörkhalla", "Shared_Morkhalla", "Shared_Morkhalla", new string[1] { "MorkBorg" })
		};

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			DetectionRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DetectionRadius", 100f, new ConfigDescription("WARNING: Increasing the detection radius may cause unintended world-generation or gameplay issues. Higher values should be used with caution. Dungeon entrances are automatically pinned when the player comes within this distance, in metres. The recommended default is 100 metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 1000f), Array.Empty<object>()));
			ScanInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScanIntervalSeconds", 2f, "How often nearby ZoneSystem locations are checked.");
			DuplicateRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DuplicateRadius", 12f, "Pins with the same dungeon label within this distance are treated as the same dungeon.");
			AlwaysShowDungeonNames = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AlwaysShowDungeonNames", true, "Create the map-name UI for dungeon pins so the dungeon name is displayed with the pin on the map.");
			CustomIconScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CustomIconScale", 1.35f, new ConfigDescription("Scale multiplier for Dungeon Map Icons custom map icons. 1.0 = normal Valheim pin size. Changes are applied live.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = -100
				}
			}));
			SelectedIconStyle = ((BaseUnityPlugin)this).Config.Bind<IconStyle>("General", "IconStyle", IconStyle.Default, new ConfigDescription("Choose the icon artwork style. Default uses the original icon set; Enhanced uses the redesigned icon set. Changes are applied live.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = -200
				}
			}));
			DungeonDefinition[] dungeons = Dungeons;
			foreach (DungeonDefinition dungeonDefinition in dungeons)
			{
				ByLabel[dungeonDefinition.Label] = dungeonDefinition;
			}
			LoadSprites();
			_harmony = new Harmony("DungeonMapIcons");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. {2}/12 Default and {3}/12 Enhanced icon sprites available. 12 automatic location types configured.", "Dungeon Map Icons", "1.0.5", DefaultSprites.Count, EnhancedSprites.Count));
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			if (!(Time.time < _nextScan))
			{
				_nextScan = Time.time + Mathf.Max(0.5f, ScanInterval.Value);
				if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)ZoneSystem.instance == (Object)null) && !((Object)(object)Minimap.instance == (Object)null))
				{
					ScanNearbyDungeons();
				}
			}
		}

		private void ScanNearbyDungeons()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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)
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(ZoneSystem), "m_locationInstances");
				IEnumerable enumerable = ((fieldInfo != null) ? (fieldInfo.GetValue(ZoneSystem.instance) as IEnumerable) : null);
				if (enumerable == null)
				{
					return;
				}
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				foreach (object item in enumerable)
				{
					object obj = ReadMember(item, "Value") ?? item;
					if (obj == null || !TryReadVector3(obj, "m_position", out var value))
					{
						continue;
					}
					float num = value.x - position.x;
					float num2 = value.z - position.z;
					if (num * num + num2 * num2 > DetectionRadius.Value * DetectionRadius.Value)
					{
						continue;
					}
					string locationName = GetLocationName(obj);
					DungeonDefinition dungeonDefinition = MatchDungeon(locationName);
					if (dungeonDefinition != null && !MapPins.HasDungeonPinNear(dungeonDefinition.Label, value, DuplicateRadius.Value))
					{
						object obj2 = MapPins.AddPin(value, dungeonDefinition.Label, dungeonDefinition.NativePinType);
						if (obj2 != null)
						{
							MapPins.ApplyCustomSprite(obj2, dungeonDefinition);
							((BaseUnityPlugin)this).Logger.LogInfo((object)("Pinned " + dungeonDefinition.Label + " at " + ((Vector3)(ref value)).ToString("F0") + " from location '" + locationName + "'."));
						}
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Dungeon scan failed: " + ex));
			}
		}

		private static string GetLocationName(object instance)
		{
			object obj = ReadMember(instance, "m_location");
			string text = ReadString(obj, "m_prefabName");
			if (string.IsNullOrEmpty(text))
			{
				text = ReadString(obj, "m_name");
			}
			if (string.IsNullOrEmpty(text))
			{
				text = ReadString(instance, "m_prefabName");
			}
			if (string.IsNullOrEmpty(text))
			{
				text = ReadString(instance, "m_name");
			}
			return text ?? string.Empty;
		}

		private static DungeonDefinition MatchDungeon(string rawName)
		{
			string text = NormalizeLocationName(rawName);
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			DungeonDefinition[] dungeons = Dungeons;
			foreach (DungeonDefinition dungeonDefinition in dungeons)
			{
				string[] locationKeys = dungeonDefinition.LocationKeys;
				foreach (string b in locationKeys)
				{
					if (string.Equals(text, b, StringComparison.OrdinalIgnoreCase))
					{
						return dungeonDefinition;
					}
				}
			}
			return null;
		}

		private static string NormalizeLocationName(string rawName)
		{
			if (string.IsNullOrWhiteSpace(rawName))
			{
				return string.Empty;
			}
			string text = rawName.Trim();
			if (text.EndsWith("(Clone)", StringComparison.OrdinalIgnoreCase))
			{
				text = text.Substring(0, text.Length - "(Clone)".Length).Trim();
			}
			return text;
		}

		private static void LoadSprites()
		{
			string text = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Paths.PluginPath;
			string[] obj = new string[4]
			{
				Path.Combine(text, "Assets", "Icons"),
				text,
				Path.Combine(Paths.PluginPath, "DungeonMapIcons", "Assets", "Icons"),
				Path.Combine(Paths.PluginPath, "Assets", "Icons")
			};
			string text2 = null;
			string[] array = obj;
			DungeonDefinition[] dungeons;
			foreach (string text3 in array)
			{
				if (!Directory.Exists(text3))
				{
					continue;
				}
				bool flag = false;
				dungeons = Dungeons;
				foreach (DungeonDefinition dungeonDefinition in dungeons)
				{
					if (File.Exists(Path.Combine(text3, dungeonDefinition.DefaultIconFile + ".png")) || File.Exists(Path.Combine(text3, dungeonDefinition.EnhancedIconFile + ".png")))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					text2 = text3;
					break;
				}
			}
			if (text2 == null)
			{
				Log.LogError((object)"Dungeon icon files not found. Checked Assets\\Icons beside the plugin and the plugin directory itself.");
				return;
			}
			Log.LogInfo((object)("Loading dungeon icons from: " + text2));
			dungeons = Dungeons;
			foreach (DungeonDefinition dungeonDefinition2 in dungeons)
			{
				LoadSprite(text2, dungeonDefinition2.DefaultIconFile, dungeonDefinition2.Label, DefaultSprites, "Default");
				if (string.Equals(dungeonDefinition2.EnhancedIconFile, dungeonDefinition2.DefaultIconFile, StringComparison.OrdinalIgnoreCase))
				{
					if (DefaultSprites.TryGetValue(dungeonDefinition2.Label, out var value))
					{
						EnhancedSprites[dungeonDefinition2.Label] = value;
					}
				}
				else
				{
					LoadSprite(text2, dungeonDefinition2.EnhancedIconFile, dungeonDefinition2.Label, EnhancedSprites, "Enhanced");
				}
			}
		}

		private static void LoadSprite(string root, string iconFile, string label, Dictionary<string, Sprite> destination, string styleName)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(iconFile))
			{
				return;
			}
			string text = Path.Combine(root, iconFile + ".png");
			if (!File.Exists(text))
			{
				Log.LogWarning((object)("Missing " + styleName + " icon: " + text));
				return;
			}
			try
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!LoadImage(val, File.ReadAllBytes(text)))
				{
					Log.LogWarning((object)("Could not decode " + text));
					return;
				}
				((Object)val).name = iconFile;
				((Texture)val).filterMode = (FilterMode)1;
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
				((Object)val2).name = "DungeonPin_" + iconFile;
				destination[label] = val2;
				Log.LogInfo((object)("Loaded " + styleName + " dungeon icon: " + iconFile + " -> " + label));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Loading " + styleName + " icon failed for " + label + ": " + ex.Message));
			}
		}

		private static bool LoadImage(Texture2D texture, byte[] bytes)
		{
			Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule", throwOnError: false);
			if (type == null)
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				for (int i = 0; i < assemblies.Length; i++)
				{
					type = assemblies[i].GetType("UnityEngine.ImageConversion", throwOnError: false);
					if (type != null)
					{
						break;
					}
				}
			}
			MethodInfo methodInfo = ((type != null) ? type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[3]
			{
				typeof(Texture2D),
				typeof(byte[]),
				typeof(bool)
			}, null) : null);
			if (methodInfo != null)
			{
				return (bool)methodInfo.Invoke(null, new object[3] { texture, bytes, false });
			}
			return false;
		}

		internal static object ReadMember(object obj, string name)
		{
			if (obj == null)
			{
				return null;
			}
			Type type = obj.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(obj);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(property != null))
			{
				return null;
			}
			return property.GetValue(obj, null);
		}

		private static string ReadString(object obj, string name)
		{
			return ReadMember(obj, name) as string;
		}

		private static bool TryReadVector3(object obj, string name, out Vector3 value)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			object obj2 = ReadMember(obj, name);
			if (obj2 is Vector3)
			{
				value = (Vector3)obj2;
				return true;
			}
			value = Vector3.zero;
			return false;
		}
	}
	internal enum IconStyle
	{
		Default,
		Enhanced
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public int? Order;
	}
	internal sealed class DungeonDefinition
	{
		internal readonly string Label;

		internal readonly string DefaultIconFile;

		internal readonly string EnhancedIconFile;

		internal readonly string[] LocationKeys;

		internal readonly int? NativePinType;

		internal DungeonDefinition(string label, string defaultIconFile, string enhancedIconFile, string[] keys, int? nativePinType = null)
		{
			Label = label;
			DefaultIconFile = defaultIconFile;
			EnhancedIconFile = enhancedIconFile;
			LocationKeys = keys;
			NativePinType = nativePinType;
		}
	}
	internal static class MapPins
	{
		private static FieldInfo _pinsField;

		private static MethodInfo _addPin;

		private static MethodInfo _createMapNamePin;

		private static bool _resolved;

		internal static void Resolve()
		{
			if (_resolved)
			{
				return;
			}
			_resolved = true;
			_pinsField = AccessTools.Field(typeof(Minimap), "m_pins");
			MethodInfo[] methods = typeof(Minimap).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name == "AddPin")
				{
					ParameterInfo[] parameters = methodInfo.GetParameters();
					if (parameters.Length >= 5 && parameters[0].ParameterType == typeof(Vector3) && parameters[2].ParameterType == typeof(string) && parameters[3].ParameterType == typeof(bool) && parameters[4].ParameterType == typeof(bool))
					{
						_addPin = methodInfo;
					}
				}
				else if (methodInfo.Name == "CreateMapNamePin")
				{
					_createMapNamePin = methodInfo;
				}
			}
		}

		internal static IList GetPins()
		{
			Resolve();
			if (!((Object)(object)Minimap.instance != (Object)null) || !(_pinsField != null))
			{
				return null;
			}
			return _pinsField.GetValue(Minimap.instance) as IList;
		}

		internal static object AddPin(Vector3 pos, string label, int? nativePinType = null)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Resolve();
			if ((Object)(object)Minimap.instance == (Object)null || _addPin == null)
			{
				return null;
			}
			ParameterInfo[] parameters = _addPin.GetParameters();
			object[] array = new object[parameters.Length];
			array[0] = pos;
			array[1] = Enum.ToObject(parameters[1].ParameterType, nativePinType ?? 3);
			array[2] = label;
			array[3] = true;
			array[4] = false;
			for (int i = 5; i < array.Length; i++)
			{
				array[i] = DefaultValue(parameters[i].ParameterType);
			}
			return _addPin.Invoke(Minimap.instance, array);
		}

		private static object DefaultValue(Type t)
		{
			if (!t.IsValueType)
			{
				return null;
			}
			return Activator.CreateInstance(t);
		}

		internal static bool HasDungeonPinNear(string label, Vector3 pos, float radius)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			IList pins = GetPins();
			if (pins == null)
			{
				return false;
			}
			float num = radius * radius;
			foreach (object item in pins)
			{
				if (string.Equals(Plugin.ReadMember(item, "m_name") as string, label, StringComparison.OrdinalIgnoreCase) && Plugin.ReadMember(item, "m_pos") is ? val)
				{
					float num2 = ((Vector3)val).x - pos.x;
					float num3 = ((Vector3)val).z - pos.z;
					if (num2 * num2 + num3 * num3 <= num)
					{
						return true;
					}
				}
			}
			return false;
		}

		internal static void ApplyCustomSprite(object pin, DungeonDefinition dungeon)
		{
			if (pin != null && dungeon != null && ((Plugin.SelectedIconStyle != null && Plugin.SelectedIconStyle.Value == IconStyle.Enhanced) ? Plugin.EnhancedSprites : Plugin.DefaultSprites).TryGetValue(dungeon.Label, out var value))
			{
				FieldInfo field = pin.GetType().GetField("m_icon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null && field.FieldType == typeof(Sprite))
				{
					field.SetValue(pin, value);
				}
			}
		}

		private static void ApplyCustomScale(object pin)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (pin != null && Plugin.CustomIconScale != null)
			{
				object obj = Plugin.ReadMember(pin, "m_uiElement");
				RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null);
				if ((Object)(object)val == (Object)null && obj is GameObject)
				{
					val = ((GameObject)obj).GetComponent<RectTransform>();
				}
				if ((Object)(object)val == (Object)null && obj is Component)
				{
					val = ((Component)obj).GetComponent<RectTransform>();
				}
				if (!((Object)(object)val == (Object)null))
				{
					float num = Mathf.Clamp(Plugin.CustomIconScale.Value, 0.5f, 3f);
					((Transform)val).localScale = new Vector3(num, num, 1f);
				}
			}
		}

		internal static void RefreshDungeonPins(Minimap map)
		{
			IList pins = GetPins();
			if (pins == null)
			{
				return;
			}
			foreach (object item in pins)
			{
				if (Plugin.ReadMember(item, "m_name") is string key && Plugin.ByLabel.TryGetValue(key, out var value))
				{
					ApplyCustomSprite(item, value);
					ApplyCustomScale(item);
					if (Plugin.AlwaysShowDungeonNames.Value)
					{
						EnsureNamePin(map, item);
					}
				}
			}
		}

		private static void EnsureNamePin(Minimap map, object pin)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			Resolve();
			if (_createMapNamePin == null)
			{
				return;
			}
			object obj = Plugin.ReadMember(pin, "m_NamePinData");
			if (obj != null)
			{
				object obj2 = Plugin.ReadMember(obj, "PinNameGameObject");
				if (obj2 is GameObject && (Object)(GameObject)obj2 != (Object)null)
				{
					return;
				}
			}
			try
			{
				if (_createMapNamePin.GetParameters().Length == 2)
				{
					object obj3 = null;
					FieldInfo fieldInfo = AccessTools.Field(typeof(Minimap), "m_mapLarge");
					FieldInfo fieldInfo2 = AccessTools.Field(typeof(Minimap), "m_pinNameRootLarge");
					FieldInfo fieldInfo3 = AccessTools.Field(typeof(Minimap), "m_pinNameRootSmall");
					object obj4 = ((fieldInfo != null) ? fieldInfo.GetValue(map) : null);
					obj3 = ((obj4 is Component && ((Component)obj4).gameObject.activeInHierarchy) ? fieldInfo2 : fieldInfo3)?.GetValue(map);
					if (obj3 != null)
					{
						_createMapNamePin.Invoke(map, new object[2] { pin, obj3 });
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Minimap), "UpdatePins")]
	internal static class MinimapUpdatePinsPatch
	{
		private static void Postfix(Minimap __instance)
		{
			try
			{
				MapPins.RefreshDungeonPins(__instance);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Refreshing dungeon pin icons failed: " + ex.Message));
			}
		}
	}
}