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 MapPinFilter v1.0.0
HideFriendMapPings.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HideFriendMapPings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+114318ac065e1c1d79b3f250f54e928d64f2dcb2")] [assembly: AssemblyProduct("HideFriendMapPings")] [assembly: AssemblyTitle("HideFriendMapPings")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 HideFriendMapPings { internal static class MapToggles { private const float Gap = 4f; private static readonly int s_sharedFadeId = Shader.PropertyToID("_SharedFade"); private static Toggle s_source; private static Toggle s_mapToggle; private static Toggle s_sharedPinsToggle; private static Toggle s_ownPinsToggle; internal static void Create(Minimap minimap) { minimap.m_showSharedMapData = true; HideGameSharedToggle(minimap); s_source = minimap.m_publicPosition; if ((Object)(object)s_source == (Object)null) { HideFriendMapPingsPlugin.Log.LogWarning((object)"Public position toggle not found, map checkboxes not created."); return; } try { s_mapToggle = CloneToggle(s_source, "HFMP_SharedMap", HideFriendMapPingsPlugin.ShowSharedMap.Value, delegate(bool isOn) { HideFriendMapPingsPlugin.ShowSharedMap.Value = isOn; }); s_sharedPinsToggle = CloneToggle(s_source, "HFMP_SharedPins", HideFriendMapPingsPlugin.ShowSharedPins.Value, delegate(bool isOn) { HideFriendMapPingsPlugin.ShowSharedPins.Value = isOn; }); s_ownPinsToggle = CloneToggle(s_source, "HFMP_OwnPins", HideFriendMapPingsPlugin.ShowOwnPins.Value, delegate(bool isOn) { HideFriendMapPingsPlugin.ShowOwnPins.Value = isOn; }); UpdatePositions(); RefreshTexts(); } catch (Exception ex) { HideFriendMapPingsPlugin.Log.LogError((object)("Could not create the map checkboxes: " + ex)); } } internal static void HideGameSharedToggle(Minimap minimap) { if ((Object)(object)minimap.m_sharedMapHint != (Object)null && minimap.m_sharedMapHint.activeSelf) { minimap.m_sharedMapHint.SetActive(false); } } internal static void UpdatePositions() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_002e: Expected O, but got Unknown //IL_002e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //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_0051: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s_source == (Object)null)) { RectTransform val = (RectTransform)((Component)s_source).transform; Rect val2 = VisualBounds(val, (RectTransform)((Transform)val).parent); float num = ((Rect)(ref val2)).height + 4f; Vector2 val3 = val.anchoredPosition + HideFriendMapPingsPlugin.TogglesOffset.Value; SetPosition(s_mapToggle, val3 + new Vector2(0f, num)); SetPosition(s_sharedPinsToggle, val3 + new Vector2(0f, num * 2f)); SetPosition(s_ownPinsToggle, val3 + new Vector2(0f, num * 3f)); } } internal static void RefreshTexts() { SetText(s_mapToggle, "$hfmp_shared_map"); SetText(s_sharedPinsToggle, "$hfmp_shared_pins"); SetText(s_ownPinsToggle, "$hfmp_own_pins"); } internal static void OnSettingsChanged() { SetIsOn(s_mapToggle, HideFriendMapPingsPlugin.ShowSharedMap.Value); SetIsOn(s_sharedPinsToggle, HideFriendMapPingsPlugin.ShowSharedPins.Value); SetIsOn(s_ownPinsToggle, HideFriendMapPingsPlugin.ShowOwnPins.Value); if ((Object)(object)Minimap.instance != (Object)null) { Minimap.instance.m_pinUpdateRequired = true; ApplySharedMapFade(Minimap.instance); } } internal static void ApplySharedMapFade(Minimap minimap) { float num = (HideFriendMapPingsPlugin.ShowSharedMap.Value ? minimap.m_sharedMapDataFade : 0f); if ((Object)(object)minimap.m_mapLargeShader != (Object)null) { minimap.m_mapLargeShader.SetFloat(s_sharedFadeId, num); } if ((Object)(object)minimap.m_mapSmallShader != (Object)null) { minimap.m_mapSmallShader.SetFloat(s_sharedFadeId, num); } } private static Rect VisualBounds(RectTransform target, RectTransform space) { //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_006d: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) HashSet<Transform> hashSet = new HashSet<Transform>(); UIGamePad[] componentsInChildren = ((Component)target).GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val in componentsInChildren) { if ((Object)(object)val.m_hint != (Object)null) { hashSet.Add(val.m_hint.transform); } } Vector2 min = new Vector2(float.MaxValue, float.MaxValue); Vector2 max = new Vector2(float.MinValue, float.MinValue); Vector3[] corners = (Vector3[])(object)new Vector3[4]; Add(target); Graphic[] componentsInChildren2 = ((Component)target).GetComponentsInChildren<Graphic>(true); foreach (Graphic val2 in componentsInChildren2) { if (!IsUnderAny(((Component)val2).transform, hashSet, (Transform)(object)target)) { Add(val2.rectTransform); } } return Rect.MinMaxRect(min.x, min.y, max.x, max.y); void Add(RectTransform rect) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) rect.GetWorldCorners(corners); Vector3[] array = corners; foreach (Vector3 val3 in array) { Vector2 val4 = Vector2.op_Implicit(((Transform)space).InverseTransformPoint(val3)); min = Vector2.Min(min, val4); max = Vector2.Max(max, val4); } } } private static bool IsUnderAny(Transform transform, HashSet<Transform> ancestors, Transform root) { Transform val = transform; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root.parent) { if (ancestors.Contains(val)) { return true; } val = val.parent; } return false; } private static Toggle CloneToggle(Toggle source, string name, bool isOn, Action<bool> onChanged) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject, ((Component)source).transform.parent, false); ((Object)val).name = name; Localize[] componentsInChildren = val.GetComponentsInChildren<Localize>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } UIGamePad[] componentsInChildren2 = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val2 in componentsInChildren2) { if ((Object)(object)val2.m_hint != (Object)null) { Object.DestroyImmediate((Object)(object)val2.m_hint); } Object.DestroyImmediate((Object)(object)val2); } Toggle component = val.GetComponent<Toggle>(); component.onValueChanged = new ToggleEvent(); component.SetIsOnWithoutNotify(isOn); ((UnityEvent<bool>)(object)component.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value) { onChanged(value); }); return component; } private static void SetIsOn(Toggle toggle, bool isOn) { if ((Object)(object)toggle != (Object)null) { toggle.SetIsOnWithoutNotify(isOn); } } private static void SetPosition(Toggle toggle, Vector2 position) { //IL_000f: 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) if ((Object)(object)toggle != (Object)null) { ((RectTransform)((Component)toggle).transform).anchoredPosition = position; } } private static void SetText(Toggle toggle, string token) { if (!((Object)(object)toggle == (Object)null)) { TMP_Text componentInChildren = ((Component)toggle).GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = Localization.instance.Localize(token); componentInChildren.textWrappingMode = (TextWrappingModes)0; } } } } [HarmonyPatch(typeof(Minimap), "Start")] internal static class Minimap_Start_Patch { private static void Postfix(Minimap __instance) { MapToggles.Create(__instance); } } [HarmonyPatch(typeof(Minimap), "Update")] internal static class Minimap_Update_Patch { private static void Postfix(Minimap __instance) { MapToggles.ApplySharedMapFade(__instance); MapToggles.HideGameSharedToggle(__instance); } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class Minimap_UpdatePins_Patch { private static readonly List<PinData> s_visiblePins = new List<PinData>(); private static void Prefix(Minimap __instance, out List<PinData> __state) { __state = null; if (HideFriendMapPingsPlugin.ShowSharedPins.Value && HideFriendMapPingsPlugin.ShowOwnPins.Value) { return; } s_visiblePins.Clear(); foreach (PinData pin in __instance.m_pins) { if (IsHidden(__instance, pin)) { __instance.DestroyPinMarker(pin); } else { s_visiblePins.Add(pin); } } __state = __instance.m_pins; __instance.m_pins = s_visiblePins; } private static void Postfix(Minimap __instance, List<PinData> __state) { if (__state != null) { __instance.m_pins = __state; s_visiblePins.Clear(); } } private static bool IsHidden(Minimap minimap, PinData pin) { if (pin.m_ownerID != 0L) { return !HideFriendMapPingsPlugin.ShowSharedPins.Value; } if (pin.m_save && pin != minimap.m_namePin) { return !HideFriendMapPingsPlugin.ShowOwnPins.Value; } return false; } } [BepInPlugin("adrirf7.HideFriendMapPings", "HideFriendMapPings", "1.0.0")] public class HideFriendMapPingsPlugin : BaseUnityPlugin { public const string ModGuid = "adrirf7.HideFriendMapPings"; public const string ModName = "HideFriendMapPings"; public const string ModVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> ShowSharedPins; internal static ConfigEntry<bool> ShowSharedMap; internal static ConfigEntry<bool> ShowOwnPins; internal static ConfigEntry<Vector2> TogglesOffset; private void Awake() { //IL_0026: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "HideFriendMapPings.adrirf7.cfg"), true, ((BaseUnityPlugin)this).Info.Metadata); ShowSharedPins = val.Bind<bool>("Map", "ShowSharedPins", true, "true = pins that other players shared with you through the cartography table are shown on the map. false = they are hidden. Also changed with the checkbox on the large map."); ShowSharedMap = val.Bind<bool>("Map", "ShowSharedMap", true, "true = map areas explored by other players (read from the cartography table) are shown. false = only the areas you explored yourself are shown. Also changed with the checkbox on the large map."); ShowOwnPins = val.Bind<bool>("Map", "ShowOwnPins", true, "true = your own pins (the ones you placed, your tombstones and discovered bosses) are shown on the map. false = they are hidden. Also changed with the checkbox on the large map."); TogglesOffset = val.Bind<Vector2>("Map", "TogglesOffset", Vector2.zero, "Moves the checkboxes of the large map by this many pixels (x = right, y = up)."); ShowSharedPins.SettingChanged += delegate { MapToggles.OnSettingsChanged(); }; ShowSharedMap.SettingChanged += delegate { MapToggles.OnSettingsChanged(); }; ShowOwnPins.SettingChanged += delegate { MapToggles.OnSettingsChanged(); }; TogglesOffset.SettingChanged += delegate { MapToggles.UpdatePositions(); }; new Harmony("adrirf7.HideFriendMapPings").PatchAll(); Translations.Register(Localization.instance, Localization.instance.GetSelectedLanguage()); Log.LogInfo((object)"HideFriendMapPings 1.0.0 loaded."); } } internal static class Translations { private const string DefaultLanguage = "English"; private static readonly string[] s_keys = new string[3] { "hfmp_shared_pins", "hfmp_shared_map", "hfmp_own_pins" }; private static readonly Dictionary<string, string[]> s_languages = new Dictionary<string, string[]> { ["English"] = new string[3] { "Shared pins", "Shared map", "My pins" }, ["Spanish"] = new string[3] { "Marcadores compartidos", "Mapa compartido", "Mis marcadores" }, ["German"] = new string[3] { "Geteilte Markierungen", "Geteilte Karte", "Eigene Markierungen" }, ["French"] = new string[3] { "Marqueurs partagés", "Carte partagée", "Mes marqueurs" }, ["Italian"] = new string[3] { "Segnalini condivisi", "Mappa condivisa", "I miei segnalini" }, ["Portuguese_Brazilian"] = new string[3] { "Marcadores compartilhados", "Mapa compartilhado", "Meus marcadores" }, ["Portuguese_European"] = new string[3] { "Marcadores partilhados", "Mapa partilhado", "Os meus marcadores" }, ["Russian"] = new string[3] { "Общие метки", "Общая карта", "Мои метки" }, ["Ukrainian"] = new string[3] { "Спільні мітки", "Спільна мапа", "Мої мітки" }, ["Polish"] = new string[3] { "Udostępnione znaczniki", "Udostępniona mapa", "Moje znaczniki" }, ["Chinese"] = new string[3] { "共享标记", "共享地图", "我的标记" }, ["Chinese_Trad"] = new string[3] { "共享標記", "共享地圖", "我的標記" }, ["Japanese"] = new string[3] { "共有ピン", "共有マップ", "自分のピン" }, ["Korean"] = new string[3] { "공유된 핀", "공유된 지도", "내 핀" } }; internal static void Register(Localization localization, string language) { if (!s_languages.TryGetValue(language, out var value)) { value = s_languages["English"]; } for (int i = 0; i < s_keys.Length; i++) { localization.AddWord(s_keys[i], value[i]); } } } [HarmonyPatch(typeof(Localization), "SetupLanguage")] internal static class Localization_SetupLanguage_Patch { private static void Postfix(Localization __instance, string language) { Translations.Register(__instance, language); MapToggles.RefreshTexts(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }