Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ImprovedMapIcons v1.0.0
ImprovedMapIcons.dll
Decompiled 15 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ImprovedMapIcons")] [assembly: AssemblyDescription("A show/hide toggle for the question-mark quest pins, and a map that remembers which icons you want on.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ImprovedMapIcons")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5534247d-7816-40b8-96fa-9fd18d7dc0af")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ImprovedMapIcons; [BepInPlugin("Pip.ImprovedMapIcons", "Pip's Improved Map Icons", "1.0.0")] [BepInProcess("valheim.exe")] public class ImprovedMapIcons : BaseUnityPlugin { [HarmonyPatch(typeof(Minimap), "SetMapData")] private class Minimap_SetMapData_ScopePatch { private static void Prefix() { _loadingMapData = true; } private static void Finalizer() { _loadingMapData = false; } } [HarmonyPatch(typeof(Minimap), "AddPin")] private class Minimap_AddPin_KeepQuestFilterPatch { private static void Prefix(Minimap __instance, PinType type, out bool __state) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected I4, but got Unknown __state = false; bool num = QuestPinToggle != null && QuestPinToggle.Value && _questPinTypes.Contains(type); bool flag = _loadingMapData && IsLegendTogglePin(type); if (num || flag) { bool[] array = VisibleIconTypesField?.GetValue(__instance) as bool[]; int num2 = (int)type; if (array != null && num2 >= 0 && num2 < array.Length && !array[num2]) { array[num2] = true; __state = true; } } } private static void Postfix(Minimap __instance, PinType type, bool __state) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown if (__state) { bool[] array = VisibleIconTypesField?.GetValue(__instance) as bool[]; int num = (int)type; if (array != null && num >= 0 && num < array.Length) { array[num] = false; } } } } [HarmonyPatch(typeof(Minimap), "ToggleIconFilter")] private class Minimap_ToggleIconFilter_LogPatch { private static void Postfix(Minimap __instance, PinType type) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected I4, but got Unknown //IL_0047: 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_0053: Expected I4, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (VerboseLogging != null && VerboseLogging.Value) { bool[] array = VisibleIconTypesField?.GetValue(__instance) as bool[]; int num = (int)type; bool flag = array == null || num < 0 || num >= array.Length || array[num]; LogInfo($"Map icon {type} ({(int)type}, {PinSpriteName(__instance, type)}) " + "is now " + (flag ? "shown" : "hidden")); } } } private const string modGUID = "Pip.ImprovedMapIcons"; private const string modName = "Pip's Improved Map Icons"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("Pip.ImprovedMapIcons"); private static ConfigEntry<bool> QuestPinToggle; private static ConfigEntry<string> QuestPinTypes; private static ConfigEntry<float> QuestPinLegendNudge; private static ConfigEntry<string> DefaultVisiblePins; private static ConfigEntry<bool> VerboseLogging; private static readonly FieldInfo VisibleIconTypesField = AccessTools.Field(typeof(Minimap), "m_visibleIconTypes"); private static readonly FieldInfo PinUpdateRequiredField = AccessTools.Field(typeof(Minimap), "m_pinUpdateRequired"); private static readonly FieldInfo[] InputHandlerActionFields = (from f in typeof(UIInputHandler).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where f.FieldType == typeof(Action<UIInputHandler>) select f).ToArray(); private static List<PinType> _questPinTypes = new List<PinType>(); private static Minimap _questToggleMap; private static GameObject _questToggleButton; private static Image _questToggleImage; private static bool _questIconTableLogged; private static bool _questLegendLogged; private static readonly FieldInfo SelectedIconsField = AccessTools.Field(typeof(Minimap), "m_selectedIcons"); private static List<PinType> _defaultVisiblePins = new List<PinType>(); private static bool _loadingMapData; private static Minimap _defaultPinsMap; private static readonly PinType[] LegendTogglePins; private void Awake() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown Game.isModded = true; QuestPinToggle = ((BaseUnityPlugin)this).Config.Bind<bool>("Quest icon", "AddQuestIcon", true, "Add a question-mark button to the map legend, below the boss icon, so quest pins can be shown and hidden like the death and boss pins. Right-click toggles them. Left-click toggles on a double-tap and does nothing on a single press, the same as the two buttons above it."); QuestPinTypes = ((BaseUnityPlugin)this).Config.Bind<string>("Quest icon", "QuestPinTypes", "Hildir1,Hildir2,Hildir3", "Which pin types the question-mark button governs. Comma separated names or numbers. The default is the three Hildir types, and is almost certainly what you want."); QuestPinLegendNudge = ((BaseUnityPlugin)this).Config.Bind<float>("Quest icon", "LegendNudge", 0f, new ConfigDescription("Extra pixels to lift the top group of map icons by. Positive moves it up, negative down. Only needed if the spacing does not come out right on your UI scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-200f, 200f), Array.Empty<object>())); DefaultVisiblePins = ((BaseUnityPlugin)this).Config.Bind<string>("Startup", "DefaultVisiblePins", "Icon1,Icon4", "Which map icons start switched on. Everything else starts off. Valheim switches them all back on every time it loads a world, so without this the same handful has to be switched off by hand at the start of every session. Comma separated names or numbers: Icon0 campfire, Icon1 house, Icon2 hammer, Icon3 plain dot, Icon4 portal, plus Death, Boss, and Hildir1, Hildir2 and Hildir3 for the question marks. Use the names - Icon4 is 6, and 4 is Death. Beds, other players, pings, shouts and event markers are never touched. Leave this empty to let the game start the way it always has."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "VerboseLogging", false, "Log every map icon switched on or off, with its name, number and sprite. The quickest way to find the name a setting wants: open the map and click an icon."); RebuildDerivedConfig(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { RebuildDerivedConfig(); }; harmony.PatchAll(); } private void Update() { UpdateQuestPinToggle(); ApplyDefaultPinVisibility(); } private static void RebuildDerivedConfig() { _questPinTypes = ParsePinTypes(QuestPinTypes.Value, "QuestPinTypes"); _defaultVisiblePins = ParsePinTypes(DefaultVisiblePins.Value, "DefaultVisiblePins"); _defaultPinsMap = null; _questIconTableLogged = false; _questLegendLogged = false; DropQuestPinToggle(); } private static List<PinType> ParsePinTypes(string raw, string setting) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) List<PinType> list = new List<PinType>(); string[] array = (raw ?? string.Empty).Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0) { continue; } PinType item; if (int.TryParse(text, out var result)) { if (!Enum.IsDefined(typeof(PinType), result)) { LogWarn($"{setting}: {result} is not a Minimap.PinType, ignoring it"); continue; } item = (PinType)result; } else { try { item = (PinType)Enum.Parse(typeof(PinType), text, ignoreCase: true); } catch (ArgumentException) { LogWarn(setting + ": '" + text + "' is not a Minimap.PinType, ignoring it"); continue; } } if (!list.Contains(item)) { list.Add(item); } } return list; } private static void DropQuestPinToggle() { if ((Object)(object)_questToggleButton != (Object)null) { Object.Destroy((Object)(object)_questToggleButton); } _questToggleButton = null; _questToggleImage = null; _questToggleMap = null; } private static void UpdateQuestPinToggle() { Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { _questToggleButton = null; _questToggleImage = null; _questToggleMap = null; } else if (QuestPinToggle == null || !QuestPinToggle.Value || _questPinTypes.Count == 0) { if ((Object)(object)_questToggleButton != (Object)null) { DropQuestPinToggle(); } } else if (instance != _questToggleMap || !((Object)(object)_questToggleButton != (Object)null)) { _questToggleMap = instance; BuildQuestPinToggle(instance); } } private unsafe static void BuildQuestPinToggle(Minimap map) { //IL_00d4: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown LogPinIconTable(map); Image val = (((Object)(object)map.m_selectedIconBoss != (Object)null) ? map.m_selectedIconBoss : map.m_selectedIconDeath); Transform val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.parent : null); Transform val3 = (((Object)(object)val2 != (Object)null) ? val2.parent : null); if ((Object)(object)val3 == (Object)null) { LogWarn("Quest pin toggle: the map legend has no boss or death button to copy, so no button was added"); return; } LogLegendHierarchy(val3); RectTransform val4 = (RectTransform)(((Object)(object)map.m_selectedIconDeath != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); RectTransform val5 = (RectTransform)(((Object)(object)map.m_selectedIconBoss != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null); Vector2 val6 = (((Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null && (Object)(object)val4 != (Object)(object)val5) ? (val5.anchoredPosition - val4.anchoredPosition) : Vector2.zero); GameObject val7 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val3, false); ((Object)val7).name = "PipsModQuestPinToggle"; val7.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1); _questToggleButton = val7; bool flag = (Object)(object)((Component)val3).GetComponent<LayoutGroup>() != (Object)null; if (!flag) { Transform transform = val7.transform; RectTransform val8 = (RectTransform)(object)((transform is RectTransform) ? transform : null); RectTransform val9 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if ((Object)(object)val8 != (Object)null && (Object)(object)val9 != (Object)null && val6 != Vector2.zero) { val8.anchoredPosition = val9.anchoredPosition + val6; } else { LogWarn("Quest pin toggle: the legend has no layout group and the spacing could not be measured, so the new button may sit on top of another"); } } StripClonedBehaviour(val7); ResizeLegendPanel(val3, Mathf.Abs(val6.y), flag); Transform val10 = (((Object)(object)val != (Object)null) ? val7.transform.Find(((Object)val).name) : null); Image val11 = (((Object)(object)val10 != (Object)null) ? ((Component)val10).GetComponent<Image>() : null); if ((Object)(object)val11 != (Object)null) { ((Behaviour)val11).enabled = false; } _questToggleImage = val7.GetComponent<Image>(); Sprite val12 = FindPinSprite(map); if ((Object)(object)_questToggleImage == (Object)null) { LogWarn("Quest pin toggle: the cloned button has no Image, so it still shows the boss icon and cannot be tinted"); } else if ((Object)(object)val12 == (Object)null) { LogWarn("Quest pin toggle: none of the types in QuestPinTypes has a sprite in Minimap.m_icons, so the button still shows the boss icon"); } else { _questToggleImage.sprite = val12; } UITooltip[] componentsInChildren = val7.GetComponentsInChildren<UITooltip>(true); foreach (UITooltip obj in componentsInChildren) { obj.m_topic = "Quest markers"; obj.m_text = "Right-click to show or hide quest markers"; } bool flag2 = false; MouseClick[] componentsInChildren2 = val7.GetComponentsInChildren<MouseClick>(true); foreach (MouseClick obj2 in componentsInChildren2) { obj2.m_rightClick.AddListener(new UnityAction(ToggleQuestPinFilter)); obj2.m_leftClick.AddListener(new UnityAction(ToggleQuestPinFilterOnDoubleTap)); flag2 = true; } if (!flag2) { UIInputHandler obj3 = val7.GetComponentInChildren<UIInputHandler>(true) ?? val7.AddComponent<UIInputHandler>(); obj3.m_onRightClick = delegate { ToggleQuestPinFilter(); }; obj3.m_onLeftClick = delegate { ToggleQuestPinFilterOnDoubleTap(); }; } SyncQuestToggleTint(VisibleIconTypesField?.GetValue(map) as bool[]); LogInfo("Quest pin toggle added to the map legend for " + string.Join(", ", _questPinTypes.Select((PinType t) => ((object)(*(PinType*)(&t))/*cast due to .constrained prefix*/).ToString()).ToArray())); } private static void StripClonedBehaviour(GameObject clone) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown MouseClick[] componentsInChildren = clone.GetComponentsInChildren<MouseClick>(true); foreach (MouseClick obj in componentsInChildren) { obj.m_leftClick = new UnityEvent(); obj.m_middleClick = new UnityEvent(); obj.m_rightClick = new UnityEvent(); } Button[] componentsInChildren2 = clone.GetComponentsInChildren<Button>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].onClick = new ButtonClickedEvent(); } UIInputHandler[] componentsInChildren3 = clone.GetComponentsInChildren<UIInputHandler>(true); foreach (UIInputHandler obj2 in componentsInChildren3) { FieldInfo[] inputHandlerActionFields = InputHandlerActionFields; for (int j = 0; j < inputHandlerActionFields.Length; j++) { inputHandlerActionFields[j].SetValue(obj2, null); } } } private static void ResizeLegendPanel(Transform group, float step, bool autoLayout) { //IL_006b: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00fa: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) if (step <= 0f) { LogWarn("Quest pin toggle: the icon spacing could not be measured, so the shaded panel was left at its original size"); return; } RectTransform val = (RectTransform)(object)((group is RectTransform) ? group : null); if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<Image>() == (Object)null) { Transform parent = group.parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponent<Image>() != (Object)null) { val = val2; } } if ((Object)(object)val == (Object)null) { LogWarn("Quest pin toggle: could not find the legend's background panel, so it was left at its original size"); return; } Vector2 sizeDelta = val.sizeDelta; val.sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y + step); float num = step + ((QuestPinLegendNudge != null) ? QuestPinLegendNudge.Value : 0f); val.anchoredPosition = new Vector2(val.anchoredPosition.x, val.anchoredPosition.y - (1f - val.pivot.y) * step + num); if (!autoLayout) { foreach (RectTransform item in (Transform)val) { RectTransform val3 = item; if (Mathf.Approximately(val3.anchorMin.y, val3.anchorMax.y)) { float y = val3.anchorMin.y; val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, val3.anchoredPosition.y + (1f - y) * step); } } } LogInfo($"Quest pin toggle: legend panel '{((Object)val).name}' grown by {step} and lifted by {num}"); } private static void LogLegendHierarchy(Transform group) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown if (_questLegendLogged || VerboseLogging == null || !VerboseLogging.Value) { return; } _questLegendLogged = true; List<string> list = new List<string>(); Transform val = group; while ((Object)(object)val != (Object)null) { list.Add(" up: " + DescribeRect(val)); if ((Object)(object)val.parent == (Object)null || list.Count > 4) { break; } val = val.parent; } foreach (Transform item in group) { Transform t = item; list.Add(" child: " + DescribeRect(t)); } LogInfo("Map legend layout:\n" + string.Join("\n", list.ToArray())); } private static string DescribeRect(Transform t) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) string[] value = (from c in ((Component)t).GetComponents<Component>() where (Object)(object)c != (Object)null select ((object)c).GetType().Name).ToArray(); RectTransform val = (RectTransform)(object)((t is RectTransform) ? t : null); string text = (((Object)(object)val == (Object)null) ? "(not a RectTransform)" : ($"pos={val.anchoredPosition} size={val.sizeDelta} " + $"anchor={val.anchorMin.y}-{val.anchorMax.y} pivot={val.pivot.y}")); return ((Object)t).name + " [" + string.Join(",", value) + "] " + text; } private static void ToggleQuestPinFilterOnDoubleTap() { if (ZInput.HasDoubleTapped()) { ToggleQuestPinFilter(); } } private static Sprite FindPinSprite(Minimap map) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references) if (map.m_icons == null) { return null; } foreach (PinType questPinType in _questPinTypes) { foreach (SpriteData icon in map.m_icons) { if (icon.m_name == questPinType && (Object)(object)icon.m_icon != (Object)null) { return icon.m_icon; } } } return null; } private static void LogPinIconTable(Minimap map) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected I4, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (_questIconTableLogged || VerboseLogging == null || !VerboseLogging.Value || map.m_icons == null) { return; } _questIconTableLogged = true; List<string> list = new List<string>(); foreach (SpriteData icon in map.m_icons) { list.Add($" {(int)icon.m_name,2} {icon.m_name,-12} " + (((Object)(object)icon.m_icon != (Object)null) ? ((Object)icon.m_icon).name : "(no sprite)")); } LogInfo("Map pin icons:\n" + string.Join("\n", list.ToArray())); } private static bool QuestPinsVisible(bool[] filters) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown if (filters == null) { return true; } foreach (PinType questPinType in _questPinTypes) { int num = (int)questPinType; if (num >= 0 && num < filters.Length && filters[num]) { return true; } } return false; } private static void SyncQuestToggleTint(bool[] filters) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_questToggleImage != (Object)null) { ((Graphic)_questToggleImage).color = (QuestPinsVisible(filters) ? Color.white : Color.gray); } } private static void ToggleQuestPinFilter() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected I4, but got Unknown Minimap instance = Minimap.instance; bool[] array = (((Object)(object)instance != (Object)null) ? (VisibleIconTypesField?.GetValue(instance) as bool[]) : null); if (array == null) { LogWarn("Quest pin toggle: could not read Minimap.m_visibleIconTypes, so nothing was hidden or shown"); return; } bool flag = !QuestPinsVisible(array); foreach (PinType questPinType in _questPinTypes) { int num = (int)questPinType; if (num >= 0 && num < array.Length) { array[num] = flag; } } PinUpdateRequiredField?.SetValue(instance, true); SyncQuestToggleTint(array); LogInfo("Quest pins " + (flag ? "shown" : "hidden")); } private static bool IsLegendTogglePin(PinType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Array.IndexOf(LegendTogglePins, type) < 0) { return _questPinTypes.Contains(type); } return true; } private unsafe static void ApplyDefaultPinVisibility() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected I4, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { _defaultPinsMap = null; } else if (DefaultVisiblePins == null || _defaultVisiblePins.Count == 0 || string.IsNullOrEmpty(DefaultVisiblePins.Value?.Trim())) { _defaultPinsMap = instance; } else { if (instance == _defaultPinsMap) { return; } _defaultPinsMap = instance; if (!(VisibleIconTypesField?.GetValue(instance) is bool[] array)) { LogWarn("Default pin visibility: could not read Minimap.m_visibleIconTypes, so the map was left as the game set it"); return; } List<string> list = new List<string>(); foreach (PinType item in LegendTogglePins.Concat(_questPinTypes).Distinct()) { int num = (int)item; if (num >= 0 && num < array.Length) { array[num] = _defaultVisiblePins.Contains(item); if (!array[num]) { list.Add(((object)(*(PinType*)(&item))/*cast due to .constrained prefix*/).ToString()); } } } PinUpdateRequiredField?.SetValue(instance, true); RefreshLegendTints(instance, array); LogInfo("Default pin visibility: showing " + string.Join(", ", _defaultVisiblePins.Select((PinType t) => ((object)(*(PinType*)(&t))/*cast due to .constrained prefix*/).ToString()).ToArray()) + "; hiding " + string.Join(", ", list.ToArray())); } } private static void RefreshLegendTints(Minimap map, bool[] filters) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected I4, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (SelectedIconsField?.GetValue(map) is Dictionary<PinType, Image> dictionary) { foreach (KeyValuePair<PinType, Image> item in dictionary) { Transform val = (((Object)(object)item.Value != (Object)null) ? ((Component)item.Value).transform.parent : null); Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null); int num = (int)item.Key; if ((Object)(object)val2 != (Object)null && num >= 0 && num < filters.Length) { ((Graphic)val2).color = (filters[num] ? Color.white : Color.gray); } } } SyncQuestToggleTint(filters); } private static string PinSpriteName(Minimap map, PinType type) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (map?.m_icons == null) { return "unknown"; } foreach (SpriteData icon in map.m_icons) { if (icon.m_name == type) { return ((Object)(object)icon.m_icon != (Object)null) ? ((Object)icon.m_icon).name : "no sprite"; } } return "not in the icon table"; } private static void LogInfo(string message) { if (VerboseLogging != null && VerboseLogging.Value) { Debug.Log((object)message); } } private static void LogWarn(string message) { Debug.LogWarning((object)message); } static ImprovedMapIcons() { PinType[] array = new PinType[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); LegendTogglePins = (PinType[])(object)array; } }