using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.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: IgnoresAccessChecksTo("Accessibility")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("assembly_googleanalytics")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_lux")] [assembly: IgnoresAccessChecksTo("assembly_postprocessing")] [assembly: IgnoresAccessChecksTo("assembly_simplemeshcombine")] [assembly: IgnoresAccessChecksTo("assembly_steamworks")] [assembly: IgnoresAccessChecksTo("assembly_sunshafts")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("com.rlabrecque.steamworks.net")] [assembly: IgnoresAccessChecksTo("ConnectedStorage")] [assembly: IgnoresAccessChecksTo("Fishlabs.Common")] [assembly: IgnoresAccessChecksTo("Fishlabs.Core")] [assembly: IgnoresAccessChecksTo("Mono.Posix")] [assembly: IgnoresAccessChecksTo("Mono.WebBrowser")] [assembly: IgnoresAccessChecksTo("netstandard")] [assembly: IgnoresAccessChecksTo("PlayFab")] [assembly: IgnoresAccessChecksTo("PlayFabParty")] [assembly: IgnoresAccessChecksTo("ui_lib")] [assembly: IgnoresAccessChecksTo("XblPCSandbox")] [assembly: IgnoresAccessChecksTo("XGamingRuntime")] [assembly: AssemblyCompany("PinFilters")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.17.0")] [assembly: AssemblyInformationalVersion("1.0.17+4809ec56943f609812a50ba8da10a6ac2c1dd5e4")] [assembly: AssemblyProduct("PinFilters")] [assembly: AssemblyTitle("PinFilters")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.17.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 PinFilters { [BepInPlugin("ashr4f.pinfilters", "PinFilters", "1.0.17")] public class PinFiltersPlugin : BaseUnityPlugin { public const string ModGuid = "ashr4f.pinfilters"; public const string ModName = "PinFilters"; public const string ModVersion = "1.0.17"; internal static ManualLogSource Log; internal static ConfigEntry Enabled; internal static ConfigEntry Hidden; internal static ConfigEntry ToggleKey; internal static ConfigEntry GroupByIcon; internal static ConfigEntry SearchAliases; internal static ConfigEntry ExcludedGroups; internal static ConfigEntry PanelWidth; internal static ConfigEntry RowHeight; internal static ConfigEntry MaxPanelHeight; internal static ConfigEntry ButtonWidth; internal static ConfigEntry ButtonHeight; internal static ConfigEntry ButtonOffsetX; internal static ConfigEntry ButtonOffsetY; private void Awake() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master switch."); Hidden = ((BaseUnityPlugin)this).Config.Bind("General", "Hidden Groups", "", "Comma-separated groups currently unchecked in the panel. Filled automatically, edit only if you want to preset it."); ToggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "Panel Key", new KeyboardShortcut((KeyCode)102, Array.Empty()), "Key that shows or hides the filter panel while the large map is open."); ExcludedGroups = ((BaseUnityPlugin)this).Config.Bind("General", "Excluded Groups", "Shout", "Comma-separated groups never listed in the panel. They stay visible on the map, they are just not filterable."); SearchAliases = ((BaseUnityPlugin)this).Config.Bind("General", "Search Aliases", "", "Extra search words per group, so everyone finds a pin with the word they know.\nFormat: group=word1|word2, separated by commas. Example: Myrt=Myrtille|Blueberry, Chard=Thistle|Chardon"); GroupByIcon = ((BaseUnityPlugin)this).Config.Bind("General", "Group By Icon", true, "Group pins by their icon, so every mod pin type gets its own line even when the mod uses no distinct pin type."); PanelWidth = ((BaseUnityPlugin)this).Config.Bind("Panel", "Width", 340f, "Panel width in pixels."); RowHeight = ((BaseUnityPlugin)this).Config.Bind("Panel", "Row Height", 30f, "Height of a list row in pixels."); MaxPanelHeight = ((BaseUnityPlugin)this).Config.Bind("Panel", "Max Height", 480f, "Maximum panel height in pixels. The list scrolls beyond that."); ButtonWidth = ((BaseUnityPlugin)this).Config.Bind("Panel", "Button Width", 150f, "Width of the map button in pixels."); ButtonHeight = ((BaseUnityPlugin)this).Config.Bind("Panel", "Button Height", 36f, "Height of the map button in pixels."); ButtonOffsetX = ((BaseUnityPlugin)this).Config.Bind("Panel", "Button Offset X", 0f, "Fine tuning of the button position, added to the built in placement. Leave at 0 unless another interface mod moves the map controls."); ButtonOffsetY = ((BaseUnityPlugin)this).Config.Bind("Panel", "Button Offset Y", 0f, "Fine tuning of the button position, added to the built in placement. Leave at 0 unless another interface mod moves the map controls."); new Harmony("ashr4f.pinfilters").PatchAll(); } private void OnGUI() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if (Enabled.Value && FilterPanel.Visible) { if ((Object)(object)Minimap.instance == (Object)null || (int)Minimap.instance.m_mode != 2) { FilterPanel.Visible = false; } else { FilterPanel.Draw(); } } } } internal static class PinGroups { internal static readonly Dictionary Icons = new Dictionary(); internal static readonly Dictionary Labels = new Dictionary(); internal static readonly Dictionary Aliases = new Dictionary(); internal static readonly HashSet HiddenGroups = new HashSet(); private static string _hiddenRaw = ""; private static bool _synced; internal static string AliasOf(string group) { if (!Aliases.TryGetValue(group, out string value)) { return ""; } return value; } internal static string LabelOf(string group) { if (Labels.TryGetValue(group, out string value) && value.Length > 0) { return value; } return group; } private static string TypeLabel(PinType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected I4, but got Unknown return (type - 4) switch { 0 => FilterPanel.T("Death", "Mort"), 1 => Loc("$piece_bed", FilterPanel.T("Bed", "Lit")), 3 => FilterPanel.T("Shout", "Cri"), 5 => FilterPanel.T("Boss", "Boss"), 6 => FilterPanel.T("Players", "Joueurs"), 8 => FilterPanel.T("Ping", "Ping"), 7 => FilterPanel.T("Event", "Événement"), 9 => FilterPanel.T("Event area", "Zone d'événement"), _ => "", }; } private static string Loc(string token, string fallback) { if (Localization.instance == null) { return fallback; } string text = Localization.instance.Localize(token); if (!string.IsNullOrEmpty(text) && !text.StartsWith("[") && !(text == token)) { return text; } return fallback; } internal static string GroupOf(PinData pin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (IsDynamicName(pin.m_type)) { return ((object)Unsafe.As(ref pin.m_type)/*cast due to .constrained prefix*/).ToString(); } string text = Normalize(pin.m_name); if (text.Length > 0) { return text; } if (PinFiltersPlugin.GroupByIcon.Value && (Object)(object)pin.m_icon != (Object)null && !string.IsNullOrEmpty(((Object)pin.m_icon).name)) { return ((Object)pin.m_icon).name; } return ((object)Unsafe.As(ref pin.m_type)/*cast due to .constrained prefix*/).ToString(); } private static bool IsDynamicName(PinType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((int)type != 12 && (int)type != 7 && (int)type != 10) { return (int)type == 4; } return true; } internal static string Normalize(string? raw) { if (string.IsNullOrEmpty(raw)) { return ""; } string text = ((Localization.instance != null) ? Localization.instance.Localize(raw) : raw); text = text.Trim(); int num; for (num = text.Length; num > 0; num--) { char c = text[num - 1]; if (!char.IsDigit(c) && c != ' ' && c != 'x' && c != 'X' && c != ':' && c != '(' && c != ')') { break; } } return text.Substring(0, num).Trim(); } internal static void Track(PinData pin) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) string key = GroupOf(pin); if (!Icons.ContainsKey(key)) { Icons[key] = pin.m_icon; } if (!Labels.TryGetValue(key, out string value) || value.Length <= 0) { string text = (IsDynamicName(pin.m_type) ? TypeLabel(pin.m_type) : Normalize(pin.m_name)); if (text.Length == 0) { text = TypeLabel(pin.m_type); } Labels[key] = text; string value2 = (((Object)(object)pin.m_icon != (Object)null) ? ((Object)pin.m_icon).name : ""); if (!string.IsNullOrEmpty(value2)) { Aliases[key] = value2; } } } internal static bool IsHidden(string group) { SyncFromConfig(); return HiddenGroups.Contains(group); } internal static void SetHidden(string group, bool hidden) { SyncFromConfig(); if (hidden) { HiddenGroups.Add(group); } else { HiddenGroups.Remove(group); } _hiddenRaw = string.Join(", ", new List(HiddenGroups).ToArray()); PinFiltersPlugin.Hidden.Value = _hiddenRaw; PinHider.Dirty = true; } private static void SyncFromConfig() { string value = PinFiltersPlugin.Hidden.Value; if (_synced && value == _hiddenRaw) { return; } _synced = true; _hiddenRaw = value; HiddenGroups.Clear(); string[] array = value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0) { HiddenGroups.Add(text); } } } } internal static class PortalPicker { private static PropertyInfo? _isOpen; private static bool _searched; internal static bool IsOpen { get { if (!_searched) { _searched = true; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("Bifrost.PortalGui"); if (!(type == null)) { _isOpen = type.GetProperty("IsOpen", AccessTools.all); break; } } } catch { _isOpen = null; } } if (_isOpen == null) { return false; } try { object value = _isOpen.GetValue(null); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch { return false; } } } } internal static class PinHider { private static readonly List _goFields = new List(); private static readonly List> _nestedGoFields = new List>(); private static bool _searched; private static readonly HashSet _touched = new HashSet(); internal static bool Dirty; internal static void Apply(Minimap map) { if (!PinFiltersPlugin.Enabled.Value || (Object)(object)map == (Object)null || PortalPicker.IsOpen) { return; } foreach (PinData pin in map.m_pins) { try { PinGroups.Track(pin); SetVisible(pin, !PinGroups.IsHidden(PinGroups.GroupOf(pin))); } catch { } } } private static void SetVisible(PinData pin, bool visible) { if (!_searched) { CacheFields(); } foreach (FieldInfo goField in _goFields) { SetAlpha(goField.GetValue(pin), visible); } foreach (KeyValuePair nestedGoField in _nestedGoFields) { object value = nestedGoField.Key.GetValue(pin); if (value != null) { SetAlpha(nestedGoField.Value.GetValue(value), visible); } } } private static void CacheFields() { _searched = true; FieldInfo[] fields = typeof(PinData).GetFields(AccessTools.all); foreach (FieldInfo fieldInfo in fields) { if (typeof(GameObject).IsAssignableFrom(fieldInfo.FieldType) || typeof(Component).IsAssignableFrom(fieldInfo.FieldType)) { _goFields.Add(fieldInfo); } else { if (!fieldInfo.FieldType.IsClass || !(fieldInfo.FieldType != typeof(string)) || typeof(Object).IsAssignableFrom(fieldInfo.FieldType)) { continue; } FieldInfo[] fields2 = fieldInfo.FieldType.GetFields(AccessTools.all); foreach (FieldInfo fieldInfo2 in fields2) { if (typeof(GameObject).IsAssignableFrom(fieldInfo2.FieldType) || typeof(Component).IsAssignableFrom(fieldInfo2.FieldType)) { _nestedGoFields.Add(new KeyValuePair(fieldInfo, fieldInfo2)); } } } } } private static void SetAlpha(object? value, bool visible) { GameObject val = null; GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (val2 != null && Object.op_Implicit((Object)(object)val2)) { val = val2; } else { Component val3 = (Component)((value is Component) ? value : null); if (val3 != null && Object.op_Implicit((Object)(object)val3)) { val = val3.gameObject; } } if ((Object)(object)val == (Object)null) { return; } CanvasGroup val4 = val.GetComponent(); if ((Object)(object)val4 == (Object)null) { if (visible) { return; } val4 = val.AddComponent(); } float num = (visible ? 1f : 0f); if (val4.alpha != num) { val4.alpha = num; val4.blocksRaycasts = visible; } _touched.Add(val4); } } internal static class FilterPanel { internal static bool Visible; internal static bool WantsPanel; internal static Rect LastRect; internal static bool Interacting; internal static bool SearchFocused; private static Vector2 _scroll; private static string _search = ""; private static GUIStyle? _labelStyle; private static GUIStyle? _placeholderStyle; private static GUIStyle? _titleStyle; private static GUIStyle? _buttonStyle; private static Texture2D? _fill; internal static void Draw() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0277: 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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: 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_033a: 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_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Expected O, but got Unknown //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Expected O, but got Unknown //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_0721: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_0897: Unknown result type (might be due to invalid IL or missing references) //IL_08ef: Unknown result type (might be due to invalid IL or missing references) //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_092f: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Expected O, but got Unknown //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0794: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (string key in PinGroups.Icons.Keys) { if (!IsExcluded(key)) { list.Add(key); } } list.Sort(StringComparer.OrdinalIgnoreCase); List list2 = new List(); foreach (string item in list) { if (_search.Length == 0 || Matches(item, _search)) { list2.Add(item); } } float value = PinFiltersPlugin.RowHeight.Value; float value2 = PinFiltersPlugin.PanelWidth.Value; float num = Mathf.Min((float)Screen.height * 0.6f, PinFiltersPlugin.MaxPanelHeight.Value); float num2 = 120f + (float)list2.Count * value; float num3 = Mathf.Min(num, num2); Rect val = MapButton.ScreenRect(); float num4; float num5; if (((Rect)(ref val)).width > 0f) { num4 = Mathf.Clamp(((Rect)(ref val)).xMax - value2, 8f, (float)Screen.width - value2 - 8f); num5 = Mathf.Clamp((float)Screen.height - ((Rect)(ref val)).yMax - num3 - 8f, 8f, (float)Screen.height - num3 - 8f); } else { num4 = (float)Screen.width - value2 - 24f; num5 = 90f; } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num4, num5, value2, num3); LastRect = val2; int num6 = 0; foreach (string item2 in list) { if (PinGroups.IsHidden(item2)) { num6++; } } string text = T("Map filters", "Filtres de carte"); if (num6 > 0) { text += ((num6 == 1) ? T(" (1 hidden)", " (1 masqué)") : T($" ({num6} hidden)", $" ({num6} masqués)")); } FillRect(val2, new Color(0.05f, 0.05f, 0.06f, 0.94f)); FillRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, 2f), new Color(1f, 1f, 1f, 0.25f)); FillRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).yMax - 2f, ((Rect)(ref val2)).width, 2f), new Color(1f, 1f, 1f, 0.25f)); FillRect(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, 2f, ((Rect)(ref val2)).height), new Color(1f, 1f, 1f, 0.25f)); FillRect(new Rect(((Rect)(ref val2)).xMax - 2f, ((Rect)(ref val2)).y, 2f, ((Rect)(ref val2)).height), new Color(1f, 1f, 1f, 0.25f)); FillRect(new Rect(((Rect)(ref val2)).x + 2f, ((Rect)(ref val2)).y + 2f, ((Rect)(ref val2)).width - 4f, 28f), new Color(1f, 1f, 1f, 0.08f)); if (_titleStyle == null) { _titleStyle = new GUIStyle(GUI.skin.label); _titleStyle.alignment = (TextAnchor)4; _titleStyle.fontStyle = (FontStyle)1; _titleStyle.fontSize = 16; _titleStyle.normal.textColor = new Color(1f, 0.85f, 0.55f); } GUI.Label(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + 3f, ((Rect)(ref val2)).width, 24f), text, _titleStyle); GUILayout.BeginArea(new Rect(((Rect)(ref val2)).x + 10f, ((Rect)(ref val2)).y + 34f, ((Rect)(ref val2)).width - 20f, ((Rect)(ref val2)).height - 44f)); Rect rect = GUILayoutUtility.GetRect(((Rect)(ref val2)).width - 16f, 22f); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - ((_search.Length > 0) ? 24f : 0f), 22f); GUI.SetNextControlName("PinFiltersSearch"); _search = GUI.TextField(val3, _search); SearchFocused = GUI.GetNameOfFocusedControl() == "PinFiltersSearch"; if (_search.Length == 0 && GUI.GetNameOfFocusedControl() != "PinFiltersSearch") { if (_placeholderStyle == null) { _placeholderStyle = new GUIStyle(GUI.skin.label); _placeholderStyle.alignment = (TextAnchor)3; _placeholderStyle.fontStyle = (FontStyle)2; _placeholderStyle.normal.textColor = new Color(1f, 1f, 1f, 0.45f); } GUI.Label(new Rect(((Rect)(ref val3)).x + 6f, ((Rect)(ref val3)).y, ((Rect)(ref val3)).width - 8f, 22f), T("Search a pin type", "Rechercher un type de pin"), _placeholderStyle); } else if (_search.Length > 0 && GUI.Button(new Rect(((Rect)(ref rect)).xMax - 22f, ((Rect)(ref rect)).y, 22f, 22f), "x")) { _search = ""; } GUILayout.Space(4f); if (_labelStyle == null) { _labelStyle = new GUIStyle(GUI.skin.label); _labelStyle.alignment = (TextAnchor)3; _labelStyle.wordWrap = false; } _scroll = GUILayout.BeginScrollView(_scroll, Array.Empty()); Rect val4 = default(Rect); Rect val5 = default(Rect); foreach (string item3 in list2) { Rect rect2 = GUILayoutUtility.GetRect(value2 - 44f, value); ((Rect)(ref val4))..ctor(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y + (value - 20f) * 0.5f, 20f, 20f); Rect slot = new Rect(((Rect)(ref rect2)).x + 28f, ((Rect)(ref rect2)).y + (value - 24f) * 0.5f, 24f, 24f); ((Rect)(ref val5))..ctor(((Rect)(ref rect2)).x + 58f, ((Rect)(ref rect2)).y, ((Rect)(ref rect2)).width - 58f, value); bool flag = !PinGroups.IsHidden(item3); bool flag2 = ((Rect)(ref rect2)).Contains(Event.current.mousePosition); if (flag2) { FillRect(rect2, new Color(1f, 1f, 1f, 0.12f)); } bool flag3 = GUI.Toggle(val4, flag, ""); DrawIcon(slot, PinGroups.Icons[item3]); Color color = GUI.color; if (!flag) { GUI.color = new Color(1f, 1f, 1f, 0.45f); } GUI.Label(val5, Display(item3), _labelStyle); GUI.color = color; if (flag2 && (int)Event.current.type == 0 && Event.current.button == 0 && !((Rect)(ref val4)).Contains(Event.current.mousePosition)) { flag3 = !flag; Event.current.Use(); } if (flag3 != flag) { PinGroups.SetHidden(item3, !flag3); } } GUILayout.EndScrollView(); if (_buttonStyle == null) { _buttonStyle = new GUIStyle(GUI.skin.button); _buttonStyle.fontSize = 15; _buttonStyle.fontStyle = (FontStyle)1; _buttonStyle.normal.textColor = new Color(1f, 0.85f, 0.55f); _buttonStyle.hover.textColor = Color.white; _buttonStyle.fixedHeight = 28f; } GUILayout.Space(6f); Rect rect3 = GUILayoutUtility.GetRect(((Rect)(ref val2)).width - 20f, 28f); float num7 = (((Rect)(ref rect3)).width - 8f) * 0.5f; Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(((Rect)(ref rect3)).x, ((Rect)(ref rect3)).y, num7, 28f); Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(((Rect)(ref rect3)).x + num7 + 8f, ((Rect)(ref rect3)).y, num7, 28f); FillRect(val6, new Color(1f, 1f, 1f, 0.1f)); FillRect(val7, new Color(1f, 1f, 1f, 0.1f)); if (GUI.Button(val6, T("All", "Tout"), _buttonStyle)) { foreach (string item4 in list2) { PinGroups.SetHidden(item4, hidden: false); } } if (GUI.Button(val7, T("None", "Aucun"), _buttonStyle)) { foreach (string item5 in list2) { PinGroups.SetHidden(item5, hidden: true); } } GUILayout.EndArea(); } private static void DrawIcon(Rect slot, Sprite? sprite) { //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_0076: 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) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Rect textureRect = sprite.textureRect; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)sprite.texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)sprite.texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)sprite.texture).height); GUI.DrawTextureWithTexCoords(slot, (Texture)(object)sprite.texture, val); } } private static void FillRect(Rect r, Color color) { //IL_0034: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fill == (Object)null) { _fill = new Texture2D(1, 1); _fill.SetPixel(0, 0, Color.white); _fill.Apply(); } Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(r, (Texture)(object)_fill); GUI.color = color2; } private static bool IsExcluded(string group) { string[] array = PinFiltersPlugin.ExcludedGroups.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length > 0 && (string.Equals(text, group, StringComparison.OrdinalIgnoreCase) || string.Equals(text, Display(group), StringComparison.OrdinalIgnoreCase))) { return true; } } return false; } private static bool Matches(string group, string needle) { if (Contains(Display(group), needle) || Contains(group, needle) || Contains(PinGroups.AliasOf(group), needle)) { return true; } string[] array = PinFiltersPlugin.SearchAliases.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }); if (array2.Length != 2 || (!Contains(group, array2[0].Trim()) && !Contains(Display(group), array2[0].Trim()))) { continue; } string[] array3 = array2[1].Split(new char[1] { '|' }); for (int j = 0; j < array3.Length; j++) { if (Contains(array3[j].Trim(), needle)) { return true; } } } return false; } private static bool Contains(string haystack, string needle) { if (!string.IsNullOrEmpty(haystack)) { return haystack.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } internal static string Display(string group) { string text = PinGroups.LabelOf(group); if (!(text == group)) { return text; } return Pretty(group); } private static string Pretty(string raw) { string text = raw.Replace("_", " ").Replace("mapicon", "").Replace("MapIcon", "") .Trim(); if (text.Length != 0) { return char.ToUpperInvariant(text[0]) + text.Substring(1); } return raw; } internal static string T(string en, string fr) { if (Localization.instance == null || !(Localization.instance.GetSelectedLanguage() == "French")) { return en; } return fr; } } internal static class MapButton { private const float BaseX = -53f; private const float BaseY = 97f; private static GameObject? _clone; private static Component? _control; private static PropertyInfo? _isOn; private static PropertyInfo? _interactable; private static bool _isToggle; private static bool _failed; internal static void Ensure(Minimap map) { //IL_013e: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clone != (Object)null || _failed) { return; } try { object? obj = AccessTools.Field(typeof(Minimap), "m_publicPosition")?.GetValue(map); Component val = (Component)((obj is Component) ? obj : null); if ((Object)(object)val == (Object)null || (Object)(object)val.transform == (Object)null) { return; } Component val2 = FindCraftButton(); _isToggle = (Object)(object)val2 == (Object)null; if ((Object)(object)val2 == (Object)null) { val2 = val; } _clone = Object.Instantiate(val2.gameObject, val.transform.parent); ((Object)_clone).name = "PinFilters_Button"; _clone.SetActive(true); Transform[] componentsInChildren = _clone.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(true); } CanvasGroup obj2 = _clone.GetComponent() ?? _clone.AddComponent(); obj2.alpha = 1f; obj2.interactable = true; obj2.blocksRaycasts = true; obj2.ignoreParentGroups = true; RectTransform component = val.GetComponent(); RectTransform component2 = _clone.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.pivot = component.pivot; component2.anchoredPosition = component.anchoredPosition + new Vector2(-53f + PinFiltersPlugin.ButtonOffsetX.Value, 97f + PinFiltersPlugin.ButtonOffsetY.Value); ((Transform)component2).localScale = Vector3.one; if (!_isToggle) { component2.sizeDelta = new Vector2(PinFiltersPlugin.ButtonWidth.Value, PinFiltersPlugin.ButtonHeight.Value); } } string value = FilterPanel.T("Map filters", "Filtres de carte"); Component[] componentsInChildren2 = _clone.GetComponentsInChildren(true); foreach (Component val3 in componentsInChildren2) { if (!((Object)(object)val3 == (Object)null)) { string name = ((object)val3).GetType().Name; if (name.Contains("TextMeshPro") || name == "Text") { ((object)val3).GetType().GetProperty("text")?.SetValue(val3, value, null); } } } componentsInChildren2 = _clone.GetComponents(); foreach (Component val4 in componentsInChildren2) { if (!((Object)(object)val4 == (Object)null)) { string name2 = ((object)val4).GetType().Name; if (name2 == "Button" || name2 == "Toggle") { _control = val4; break; } } } if ((Object)(object)_control == (Object)null) { throw new Exception("no button or toggle on the clone"); } _interactable = ((object)_control).GetType().GetProperty("interactable"); _interactable?.SetValue(_control, true, null); ForceLabelVisible(); string name3 = (_isToggle ? "onValueChanged" : "onClick"); object obj3 = ((object)_control).GetType().GetProperty(name3)?.GetValue(_control, null); obj3?.GetType().GetMethod("RemoveAllListeners")?.Invoke(obj3, null); if (_isToggle) { _isOn = ((object)_control).GetType().GetProperty("isOn"); _isOn?.SetValue(_control, FilterPanel.Visible, null); ReplaceCheckmark(); } else { AddClickListener(obj3); } } catch (Exception ex) { PinFiltersPlugin.Log.LogWarning((object)("PinFilters: map button not created (" + ex.Message + "). The panel key still works.")); if ((Object)(object)_clone != (Object)null) { Object.Destroy((Object)(object)_clone); } _clone = null; _control = null; _failed = true; } } private static Component? FindCraftButton() { try { if ((Object)(object)InventoryGui.instance == (Object)null) { return null; } string[] array = new string[3] { "m_craftButton", "m_repairButton", "m_upgradeButton" }; foreach (string text in array) { object? obj = AccessTools.Field(typeof(InventoryGui), text)?.GetValue(InventoryGui.instance); Component val = (Component)((obj is Component) ? obj : null); if (val != null && (Object)(object)val != (Object)null) { return val; } } } catch { } return null; } private static void AddClickListener(object? handler) { if (handler == null) { return; } MethodInfo[] methods = handler.GetType().GetMethods(); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != "AddListener")) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1) { Delegate obj = Delegate.CreateDelegate(parameters[0].ParameterType, typeof(MapButton).GetMethod("OnClick", AccessTools.all)); methodInfo.Invoke(handler, new object[1] { obj }); break; } } } } private static void ForceLabelVisible() { //IL_0089: 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) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clone == (Object)null) { return; } Component[] componentsInChildren = _clone.GetComponentsInChildren(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } string name = ((object)val).GetType().Name; if (!name.Contains("TextMeshPro") && name != "Text") { continue; } PropertyInfo property = ((object)val).GetType().GetProperty("color"); if (property?.GetValue(val, null) is Color val2) { float num = Mathf.Max(val2.r, Mathf.Max(val2.g, val2.b)); if (val2.a < 1f || num < 0.6f) { property.SetValue(val, Color.white, null); } } } } private static void KeepEnabled() { if ((Object)(object)_control == (Object)null || _interactable == null) { return; } try { object value = _interactable.GetValue(_control, null); if (value is bool && !(bool)value) { _interactable.SetValue(_control, true, null); } } catch { _interactable = null; } } private static void OnClick() { FilterPanel.Visible = !FilterPanel.Visible; FilterPanel.WantsPanel = FilterPanel.Visible; } private static void ReplaceCheckmark() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clone == (Object)null) { return; } Sprite val = PickIcon(); if ((Object)(object)val == (Object)null) { return; } Component[] componentsInChildren = _clone.GetComponentsInChildren(true); foreach (Component val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !(((object)val2).GetType().Name != "Image") && !((Object)(object)val2.transform == (Object)(object)_clone.transform)) { PropertyInfo property = ((object)val2).GetType().GetProperty("sprite"); if (!(property == null)) { property.SetValue(val2, val, null); ((object)val2).GetType().GetProperty("color")?.SetValue(val2, Color.white, null); } } } } private static Sprite? PickIcon() { //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_002f: 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_0036: Invalid comparison between Unknown and I4 //IL_0038: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null || instance.m_icons == null) { return null; } foreach (SpriteData icon in instance.m_icons) { if ((int)icon.m_name == 3 && (Object)(object)icon.m_icon != (Object)null) { return icon.m_icon; } } foreach (SpriteData icon2 in instance.m_icons) { if ((Object)(object)icon2.m_icon != (Object)null) { return icon2.m_icon; } } return null; } internal static Rect ScreenRect() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clone == (Object)null) { return Rect.zero; } RectTransform component = _clone.GetComponent(); if ((Object)(object)component == (Object)null) { return Rect.zero; } Vector3[] array = (Vector3[])(object)new Vector3[4]; component.GetWorldCorners(array); float num = Mathf.Min(array[0].x, array[2].x); float num2 = Mathf.Max(array[0].x, array[2].x); float num3 = Mathf.Min(array[0].y, array[1].y); float num4 = Mathf.Max(array[0].y, array[1].y); return new Rect(num, num3, num2 - num, num4 - num3); } internal static void ApplyOffsets(Minimap map) { //IL_0065: 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_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_0096: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clone == (Object)null) { return; } KeepEnabled(); object? obj = AccessTools.Field(typeof(Minimap), "m_publicPosition")?.GetValue(map); object? obj2 = ((obj is Component) ? obj : null); RectTransform val = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); RectTransform component = _clone.GetComponent(); if ((Object)(object)val == (Object)null || (Object)(object)component == (Object)null) { return; } Vector2 val2 = val.anchoredPosition + new Vector2(-53f + PinFiltersPlugin.ButtonOffsetX.Value, 97f + PinFiltersPlugin.ButtonOffsetY.Value); if (component.anchoredPosition != val2) { component.anchoredPosition = val2; } if (!_isToggle) { Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(PinFiltersPlugin.ButtonWidth.Value, PinFiltersPlugin.ButtonHeight.Value); if (component.sizeDelta != val3) { component.sizeDelta = val3; } } if (!_clone.activeSelf) { _clone.SetActive(true); } } internal static void Sync() { if (!_isToggle || (Object)(object)_control == (Object)null || _isOn == null) { return; } try { object value = _isOn.GetValue(_control, null); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; if (flag2 != FilterPanel.Visible) { if (FilterPanel.WantsPanel != FilterPanel.Visible) { _isOn.SetValue(_control, FilterPanel.Visible, null); } else { FilterPanel.Visible = flag2; } } FilterPanel.WantsPanel = FilterPanel.Visible; } catch { _control = null; } } } [HarmonyPatch(typeof(Minimap), "Update")] internal static class Minimap_Update_Block_Patch { internal static bool Blocked; [HarmonyPriority(800)] private static bool Prefix(Minimap __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_002f: 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_0054: Unknown result type (might be due to invalid IL or missing references) Blocked = false; if (!PinFiltersPlugin.Enabled.Value || !FilterPanel.Visible) { return true; } if ((int)__instance.m_mode != 2) { return true; } if (!FilterPanel.Interacting) { Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); if (!((Rect)(ref FilterPanel.LastRect)).Contains(val)) { return true; } } Blocked = true; return false; } } [HarmonyPatch(typeof(Player), "SetControls")] internal static class Player_SetControls_Patch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool jump, ref bool autoRun, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool block) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (PinFiltersPlugin.Enabled.Value && FilterPanel.Visible && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { movedir = Vector3.zero; jump = false; autoRun = false; attack = false; attackHold = false; secondaryAttack = false; block = false; } } } [HarmonyPatch(typeof(Minimap), "UpdatePins")] internal static class Minimap_UpdatePins_Patch { private static void Postfix(Minimap __instance) { PinHider.Apply(__instance); } } [HarmonyPatch(typeof(Minimap), "Update")] internal static class Minimap_Update_Patch { [HarmonyPriority(0)] private static void Prefix(Minimap __instance) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0069: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) if (!PinFiltersPlugin.Enabled.Value) { return; } if ((int)__instance.m_mode != 2) { FilterPanel.Visible = false; MapButton.Sync(); return; } MapButton.Ensure(__instance); MapButton.ApplyOffsets(__instance); MapButton.Sync(); if (PinHider.Dirty || Minimap_Update_Block_Patch.Blocked) { PinHider.Dirty = false; PinHider.Apply(__instance); } if (Minimap.InTextInput() || (FilterPanel.Visible && FilterPanel.SearchFocused)) { return; } KeyboardShortcut value = PinFiltersPlugin.ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { FilterPanel.Visible = !FilterPanel.Visible; } if (FilterPanel.Visible && Input.GetMouseButtonDown(0) && !FilterPanel.Interacting) { Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); Rect val2 = MapButton.ScreenRect(); int num; if (((Rect)(ref val2)).width > 0f) { Rect val3 = new Rect(((Rect)(ref val2)).x, (float)Screen.height - ((Rect)(ref val2)).yMax, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height); num = (((Rect)(ref val3)).Contains(val) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; if (!((Rect)(ref FilterPanel.LastRect)).Contains(val) && !flag) { FilterPanel.Visible = false; } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }