Decompiled source of Pintervention v1.3.0
Pintervention.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Pintervention")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Pintervention")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("334130a7-42b2-4177-a221-cedf40d6899d")] [assembly: AssemblyFileVersion("1.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 Pintervention { public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<bool> ReadPinsOnInteract { get; private set; } public static ConfigEntry<bool> ReadRevealedMapOnInteract { get; private set; } public static ConfigEntry<bool> WritePinsOnInteract { get; private set; } public static ConfigEntry<bool> WriteRevealedMapOnInteract { get; private set; } public static ConfigEntry<KeyboardShortcut> DisplayFilterPanel { get; private set; } public static ConfigEntry<Vector2> PlayerPinFilterSizeDelta { get; private set; } public static ConfigEntry<Vector2> PlayerPinFilterPosition { get; private set; } public static void BindConfig(ConfigFile config) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); ReadPinsOnInteract = config.BindInOrder("CartographyTable", "readPinsOnInteract", defaultValue: true, "Allows not taking pins when reading from cartography table."); ReadRevealedMapOnInteract = config.BindInOrder("CartographyTable", "readRevealedMapOnInteract", defaultValue: true, "Allows not taking shared map data when reading from cartography table."); WritePinsOnInteract = config.BindInOrder("CartographyTable", "writePinsOnInteract", defaultValue: true, "Allows not writing pins when writing to cartography table."); WriteRevealedMapOnInteract = config.BindInOrder("CartographyTable", "writeRevealedMapOnInteract", defaultValue: true, "Allows not writing shared map data when writing to cartography table."); DisplayFilterPanel = config.BindInOrder<KeyboardShortcut>("Hotkeys", "displayFilterPanelShortcut", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Keyboard shortcut for the displaying filter panel with minimap open."); PlayerPinFilterSizeDelta = config.BindInOrder<Vector2>("PlayerPinFilter.Panel", "playerListPanelSizeDelta", new Vector2(400f, 400f), "The value for the PlayerPinFilter.Panel sizeDelta (width/height in pixels)."); PlayerPinFilterPosition = config.BindInOrder<Vector2>("PlayerPinFilter.Panel", "pinFilterPanelPanelPosition", new Vector2(-25f, 0f), "The value for the PlayerPinFilter.Panel position (relative to pivot/anchors)."); } } public static class PinDataExtensions { public static PinData SetType(this PinData pin, PinType pinType) { //IL_0001: 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) pin.m_type = pinType; return pin; } public static PinData SetName(this PinData pin, string name) { pin.m_name = name; return pin; } public static PinData SetPosition(this PinData pin, Vector3 position) { //IL_0001: 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) pin.m_pos = position; return pin; } public static PinData SetSave(this PinData pin, bool save) { pin.m_save = save; return pin; } public static PinData SetChecked(this PinData pin, bool isChecked) { pin.m_checked = isChecked; return pin; } public static PinData SetOwnerID(this PinData pin, long ownerID) { pin.m_ownerID = ownerID; return pin; } public static PinData SetAuthor(this PinData pin, string author) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) pin.m_author = new PlatformUserID(author); return pin; } public static PinData SetIcon(this PinData pin, Sprite icon) { pin.m_icon = icon; return pin; } } public static class FileUtils { public static string GetPath() { return Path.Combine(Utils.GetSaveDataPath((FileSource)1), "characters", "pinNames"); } public static string GetFilename() { return Path.Combine(GetPath(), StringExtensionMethods.GetStableHashCode($"{ZNet.instance.GetWorldUID()}") + ".csv"); } public static string GetFilteredFilename() { return Path.Combine(GetPath(), StringExtensionMethods.GetStableHashCode($"{ZNet.instance.GetWorldUID()}") + "_filtered.csv"); } public static int HashPid(long pid) { return StringExtensionMethods.GetStableHashCode($"{pid}"); } } public static class NameManager { private static readonly string _mapPinsName = "World & Player Pins"; private static int _unknownPlayerCount = 0; public static Dictionary<long, string> PlayerNamesById { get; private set; } = new Dictionary<long, string>(); public static void LoadPlayerNames() { ReadNamesFromFile(); } private static void AddLocalPlayerName() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && !PlayerNamesById.ContainsKey(Player.m_localPlayer.GetPlayerID())) { PlayerNamesById.Add(Player.m_localPlayer.GetPlayerID(), Player.m_localPlayer.GetPlayerName()); } } public static string GetPlayerNameById(long pid) { if (pid == 0L) { return _mapPinsName; } if (pid == Player.m_localPlayer.GetPlayerID()) { return Player.m_localPlayer.GetPlayerName(); } if (PlayerNamesById.ContainsKey(pid)) { return PlayerNamesById[pid]; } return AssignNextUnknownPlayer(pid); } private static string AssignNextUnknownPlayer(long pid) { _unknownPlayerCount++; string text = $"Unknown Player {_unknownPlayerCount}"; if (!PlayerNamesById.ContainsKey(pid)) { PlayerNamesById.Add(pid, text); } return text; } public static void AddPlayerName(long pid, string name) { if (!PlayerNamesById.ContainsKey(pid) || PlayerNamesById[pid].Contains("Unknown")) { if (PlayerNamesById.ContainsKey(pid)) { PlayerNamesById[pid] = name; } else { PlayerNamesById.Add(pid, name); } } } public static string PidNameMapToRow(int hashedPid, string name) { return string.Join(",", hashedPid.ToString(), name); } public static void WriteNamesToFile() { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return; } Dictionary<long, string> namesToWrite = GetNamesToWrite(); if (namesToWrite.Count == 0) { return; } if (!Directory.Exists(FileUtils.GetPath())) { Directory.CreateDirectory(FileUtils.GetPath()); } using StreamWriter streamWriter = File.CreateText(FileUtils.GetFilename()); streamWriter.AutoFlush = true; foreach (KeyValuePair<long, string> item in namesToWrite) { if (item.Key != Player.m_localPlayer.GetPlayerID() && !item.Value.StartsWith("Unknown")) { streamWriter.WriteLine(PidNameMapToRow(FileUtils.HashPid(item.Key), item.Value)); } } } public static Dictionary<long, string> GetNamesToWrite() { Dictionary<long, string> dictionary = new Dictionary<long, string>(); foreach (KeyValuePair<long, string> item in PlayerNamesById) { if (item.Key != Player.m_localPlayer.GetPlayerID() && !item.Value.StartsWith("Unknown")) { dictionary.Add(item.Key, item.Value); } } return dictionary; } public static void ReadNamesFromFile() { if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.GetWorldUID().Equals(0L)) { Pintervention.LogWarning("Could not read saved player names from file as ZNet instance is null."); return; } if (!File.Exists(FileUtils.GetFilename())) { Pintervention.LogInfo("No saved names to load from " + FileUtils.GetFilename() + "."); return; } Pintervention.LogInfo("Loading saved player names from " + FileUtils.GetFilename()); Dictionary<int, string> dictionary = new Dictionary<int, string>(); using (StreamReader streamReader = new StreamReader(FileUtils.GetFilename())) { while (!streamReader.EndOfStream) { string[] array = streamReader.ReadLine().Split(new char[1] { ',' }); int key = int.Parse(array[0]); string value = array[1]; dictionary.Add(key, value); } } foreach (long foreignPinOwner in PinOwnerManager.ForeignPinOwners) { if (dictionary.ContainsKey(FileUtils.HashPid(foreignPinOwner)) && !PlayerNamesById.ContainsKey(foreignPinOwner)) { PlayerNamesById.Add(foreignPinOwner, dictionary[FileUtils.HashPid(foreignPinOwner)]); } } } } public static class PinOwnerManager { private static readonly HashSet<PinData> _localPlayerPins = new HashSet<PinData>(); public static List<long> ForeignPinOwners { get; private set; } = new List<long>(); public static List<long> FilteredPinOwners { get; private set; } = new List<long>(); public static bool Initialize() { if (!Object.op_Implicit((Object)(object)Minimap.instance) || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || IsInitialized()) { return false; } UpdatePinOwners(); NameManager.LoadPlayerNames(); LoadFilteredPinOwners(); return true; } public static void UpdatePinOwners() { FindPinOwners(); AddAllLocalPlayerPins(); } public static void AddAllLocalPlayerPins() { if (!Object.op_Implicit((Object)(object)Minimap.instance) || !Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return; } foreach (PinData pin in Minimap.instance.m_pins) { if (pin.m_ownerID == 0L && !IsWorldPin(pin)) { AddLocalPlayerPin(pin); } } } public static void FindPinOwners() { if (Object.op_Implicit((Object)(object)Minimap.instance)) { ForeignPinOwners = Minimap.instance.m_pins.Select((PinData x) => x.m_ownerID).Distinct().ToList(); ForeignPinOwners.Add(Player.m_localPlayer.GetPlayerID()); ForeignPinOwners.Sort(); } } public static bool IsWorldPin(PinData pin) { if (!Object.op_Implicit((Object)(object)Minimap.instance)) { return true; } if (Minimap.instance.m_locationPins.Values.Contains(pin) || Minimap.instance.m_playerPins.Contains(pin) || Minimap.instance.m_shoutPins.Contains(pin) || Minimap.instance.m_randEventPin == pin) { return true; } return false; } public static void Clear() { if (ForeignPinOwners.Any()) { ForeignPinOwners.Clear(); ForeignPinOwners = new List<long>(); } if (FilteredPinOwners.Any()) { FilteredPinOwners.Clear(); FilteredPinOwners = new List<long>(); } } public static long GetForeignPinOwnerAtIndex(int index) { return ForeignPinOwners[index]; } public static Dictionary<long, ZDO> GetZDOsByPlayerId(List<long> playerIds) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) Dictionary<ZDOID, ZDO> objectsByID = ZDOMan.s_instance.m_objectsByID; HashSet<long> hashSet = new HashSet<long>(); foreach (long playerId in playerIds) { hashSet.Add(playerId); } HashSet<long> hashSet2 = hashSet; Dictionary<long, ZDO> dictionary = new Dictionary<long, ZDO>(); long num = default(long); foreach (ZNetPeer peer in ZNet.m_instance.m_peers) { if (!(peer.m_characterID == ZDOID.None) && objectsByID.TryGetValue(peer.m_characterID, out var value) && ZDOExtraData.GetLong(value.m_uid, ZDOVars.s_playerID, ref num) && hashSet2.Contains(num)) { dictionary.Add(num, value); hashSet2.Remove(num); if (hashSet2.Count <= 0) { break; } } } return dictionary; } public static void RemoveForeignPinOwner(long pid) { if (ForeignPinOwners.Contains(pid)) { ForeignPinOwners.Remove(pid); } } public static void FilterPins() { if (!IsInitialized()) { Initialize(); } if (!FilteredPinOwners.Any()) { return; } foreach (long filteredPinOwner in FilteredPinOwners) { foreach (PinData item in GetPinsByPid(filteredPinOwner)) { Minimap.instance.DestroyPinMarker(item); } } } public static void SortPinOwnersByName() { ForeignPinOwners = ForeignPinOwners.OrderBy((long x) => NameManager.GetPlayerNameById(x)).ToList(); } public static List<PinData> GetPinsByPid(long pid) { if (pid == 0L) { AddAllLocalPlayerPins(); return Minimap.instance.m_pins.Where((PinData x) => x.m_ownerID == pid && !_localPlayerPins.Contains(x)).ToList(); } if (pid == Player.m_localPlayer.GetPlayerID()) { return _localPlayerPins.ToList(); } return Minimap.instance.m_pins.Where((PinData x) => x.m_ownerID == pid).ToList(); } public static bool IsFiltered(long pid) { if (!FilteredPinOwners.Contains(pid)) { return false; } return true; } public static void ToggleFilter(long pid) { if (FilteredPinOwners.Contains(pid)) { FilteredPinOwners.Remove(pid); } else { FilteredPinOwners.Add(pid); } } public static bool IsInitialized() { if (!ForeignPinOwners.Any()) { return false; } return true; } public static void AddLocalPlayerPin(PinData pin) { if (!_localPlayerPins.Contains(pin)) { _localPlayerPins.Add(pin); } } public static void RemoveLocalPlayerPin(PinData pin) { _localPlayerPins.Remove(pin); } public static string PidToRow(int hashedPid) { return string.Join(",", hashedPid.ToString()); } public static void WriteFilteredPlayersToFile() { if (!FilteredPinOwners.Any()) { return; } if (!Directory.Exists(FileUtils.GetPath())) { Directory.CreateDirectory(FileUtils.GetPath()); } using StreamWriter streamWriter = File.CreateText(FileUtils.GetFilteredFilename()); streamWriter.AutoFlush = true; foreach (long filteredPinOwner in FilteredPinOwners) { streamWriter.WriteLine(PidToRow(FileUtils.HashPid(filteredPinOwner))); } } public static void LoadFilteredPinOwners() { ReadFilteredPinOwnersFromFile(); } public static void ReadFilteredPinOwnersFromFile() { if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.GetWorldUID().Equals(0L)) { Pintervention.LogWarning("Could not read saved filtered pin owners from file as ZNet instance is null."); return; } if (!File.Exists(FileUtils.GetFilteredFilename())) { Pintervention.LogInfo("No saved filtered pin owners to load from " + FileUtils.GetFilteredFilename() + "."); return; } Pintervention.LogInfo("Loading saved filter state from " + FileUtils.GetFilteredFilename()); List<long> list = new List<long>(); using (StreamReader streamReader = new StreamReader(FileUtils.GetFilteredFilename())) { while (!streamReader.EndOfStream) { int num = int.Parse(streamReader.ReadLine().Split(new char[1] { ',' })[0]); list.Add(num); } } foreach (long foreignPinOwner in ForeignPinOwners) { if (list.Contains(FileUtils.HashPid(foreignPinOwner)) && !FilteredPinOwners.Contains(foreignPinOwner)) { FilteredPinOwners.Add(foreignPinOwner); } } } } public static class PlayerFilterPanelManager { private static PlayerPinFilterPanel _filterPanel; public static void ToggleFilterPanel() { //IL_004d: 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_0075: 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) if (!Object.op_Implicit((Object)(object)_filterPanel?.Panel)) { _filterPanel = new PlayerPinFilterPanel(Minimap.m_instance.m_largeRoot.transform); _filterPanel.Panel.RectTransform().SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetPosition(PluginConfig.PlayerPinFilterPosition.Value) .SetSizeDelta(PluginConfig.PlayerPinFilterSizeDelta.Value); PluginConfig.PlayerPinFilterPosition.OnSettingChanged(delegate(Vector2 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) _filterPanel?.Panel.Ref<GameObject>()?.RectTransform().SetPosition(position); }); PluginConfig.PlayerPinFilterSizeDelta.OnSettingChanged(delegate(Vector2 sizeDelta) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_filterPanel?.Panel)) { _filterPanel.Panel.RectTransform().SetSizeDelta(sizeDelta); } }); _filterPanel.PanelDragger.OnPanelEndDrag += delegate(object _, Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) PluginConfig.PlayerPinFilterPosition.Value = Vector2.op_Implicit(position); }; _filterPanel.PanelResizer.OnPanelEndResize += delegate(object _, Vector2 sizeDelta) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PluginConfig.PlayerPinFilterSizeDelta.Value = sizeDelta; }; _filterPanel.Panel.SetActive(false); } bool num = !_filterPanel.Panel.activeSelf; _filterPanel.Panel.SetActive(!_filterPanel.Panel.activeSelf); if (num) { _filterPanel.UpdatePanel(); } } public static void UpdatePanel() { if (Object.op_Implicit((Object)(object)_filterPanel?.Panel)) { _filterPanel.UpdatePanel(); } } public static void UpdatePinCounts() { if (Object.op_Implicit((Object)(object)_filterPanel?.Panel)) { _filterPanel.UpdatePinCounts(); } } } public static class SharedMapDataManager { public static void ReadMapData(ZDO zdo) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown byte[] byteArray = zdo.GetByteArray(ZDOVars.s_data, (byte[])null); if (byteArray == null) { Pintervention.LogWarning("No data found in zdo data field."); return; } if (!PluginConfig.ReadRevealedMapOnInteract.Value && !PluginConfig.ReadPinsOnInteract.Value) { Pintervention.MessageLocalPlayer("All cartography table data disabled on read."); return; } ZPackage val = new ZPackage(Utils.Decompress(byteArray)); int version = val.ReadInt(); if (PluginConfig.ReadPinsOnInteract.Value) { WritePinsToMap(val, version); Pintervention.MessageLocalPlayer("Added pins from cartography table to map."); } else if (PluginConfig.ReadRevealedMapOnInteract.Value) { WriteExploredAreaToMap(val, version); Pintervention.MessageLocalPlayer("Added revealed area from cartography table to map."); } } public static void WritePinsToMap(ZPackage zPackage, int version) { if (Minimap.instance.ReadExploredArray(zPackage, version) == null) { Pintervention.LogWarning("Failed to read explored map from ZPackage."); return; } List<PinData> list = ReadImportedPins(zPackage, version); if (!list.Any()) { Pintervention.MessageLocalPlayer("No new pins found to copy to player map."); } else { Minimap.instance.m_pins.AddRange(list); } } public static List<PinData> ReadImportedPins(ZPackage zPackage, int version) { List<PinData> list = new List<PinData>(); if (version < 2) { return list; } int num = zPackage.ReadInt(); for (int i = 0; i < num; i++) { PinData val = ReadPin(zPackage, version); if (val != null) { list.Add(val); } } return list; } private static PinData ReadPin(ZPackage zPackage, int version) { //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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0056: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown long ownerID = zPackage.ReadLong(); string name = zPackage.ReadString(); Vector3 val = zPackage.ReadVector3(); PinType val2 = (PinType)zPackage.ReadInt(); bool isChecked = zPackage.ReadBool(); string author = ((version >= 3) ? zPackage.ReadString() : string.Empty); if (Minimap.instance.HavePinInRange(val, 1f)) { return null; } PinData val3 = PinDataExtensions.SetOwnerID(new PinData(), ownerID).SetName(name).SetPosition(val) .SetType(val2) .SetChecked(isChecked) .SetAuthor(author) .SetIcon(Minimap.instance.GetSprite(val2)); if (!string.IsNullOrEmpty(val3.m_name)) { val3.m_NamePinData = new PinNameData(val3); } return val3; } public static bool WriteExploredAreaToMap(ZPackage zPackage, int version) { Minimap instance = Minimap.m_instance; List<bool> list = instance.ReadExploredArray(zPackage, version); if (list == null) { return false; } bool flag = false; bool[] explored = instance.m_explored; bool[] exploredOthers = instance.m_exploredOthers; int textureSize = instance.m_textureSize; for (int i = 0; i < textureSize; i++) { for (int j = 0; j < textureSize; j++) { int num = i * textureSize + j; if (list[num] && (exploredOthers[num] || explored[num]) != list[num] && instance.ExploreOthers(j, i)) { flag = true; } } } if (!flag) { return false; } instance.m_fogTexture.Apply(); return true; } } public sealed class LabelCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TMP_Text Label { get; private set; } public LabelCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.Image(); Label = CreateChildLabel(Cell.transform); } private GameObject CreateChildCell(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(4, 4, 4, 4) .SetSpacing(4f) .SetChildAlignment((TextAnchor)4); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(64, 64, 8, (FilterMode)1)) .SetColor(new Color(0.2f, 0.2f, 0.2f, 0.5f)); val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2); val.AddComponent<LayoutElement>().SetPreferred(150f, null).SetFlexible(1f); return val; } private TMP_Text CreateChildLabel(Transform parentTransform) { TextMeshProUGUI obj = UIBuilder.CreateTMPLabel(parentTransform); ((TMP_Text)(object)obj).SetName<TMP_Text>("Label"); ((TMP_Text)obj).alignment = (TextAlignmentOptions)513; ((TMP_Text)obj).text = "Label"; ((Component)obj).gameObject.AddComponent<LayoutElement>().SetFlexible(1f); return (TMP_Text)(object)obj; } } public sealed class ValueCell { private static readonly Lazy<ColorBlock> InputFieldColorBlock = new Lazy<ColorBlock>((Func<ColorBlock>)delegate { //IL_0002: 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_0039: 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_0074: 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_00b1: Unknown result type (might be due to invalid IL or missing references) ColorBlock result = default(ColorBlock); ((ColorBlock)(ref result)).normalColor = new Color(1f, 1f, 1f, 0.9f); ((ColorBlock)(ref result)).highlightedColor = new Color(0.565f, 0.792f, 0.976f); ((ColorBlock)(ref result)).disabledColor = new Color(0.2f, 0.2f, 0.2f, 0.8f); ((ColorBlock)(ref result)).pressedColor = new Color(0.647f, 0.839f, 0.655f); ((ColorBlock)(ref result)).selectedColor = new Color(1f, 0.878f, 0.51f); ((ColorBlock)(ref result)).colorMultiplier = 1f; ((ColorBlock)(ref result)).fadeDuration = 0.25f; return result; }); public GameObject Cell { get; private set; } public Image Background { get; private set; } public TMP_InputField InputField { get; private set; } public ValueCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.Image(); InputField = CreateChildInputField(Cell.transform); ((Selectable)(object)InputField).SetTargetGraphic((Graphic)(object)Background); } private GameObject CreateChildCell(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(64, 64, 8, (FilterMode)1)) .SetColor(new Color(0.5f, 0.5f, 0.5f, 0.5f)); val.AddComponent<RectMask2D>(); val.AddComponent<LayoutElement>(); return val; } private TMP_InputField CreateChildInputField(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_00b6: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.RectTransform().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); TMP_Text val2 = (TMP_Text)(object)UIBuilder.CreateTMPLabel(val.transform); val2.SetName<TMP_Text>("InputField.Text"); val2.richText = false; val2.alignment = (TextAlignmentOptions)513; val2.text = "InputField.Text"; TMP_InputField obj = ((Component)parentTransform).gameObject.AddComponent<TMP_InputField>(); obj.textComponent = val2; obj.textViewport = val.GetComponent<RectTransform>(); ((Selectable)obj).transition = (Transition)1; ((Selectable)obj).colors = InputFieldColorBlock.Value; obj.onFocusSelectAll = false; ((Selectable)(object)obj).SetNavigationMode((Mode)0); return obj; } } public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Vector2 _lastMousePosition; public RectTransform TargetRectTransform; public event EventHandler<Vector3> OnPanelEndDrag; public void OnBeginDrag(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: 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) Vector2 val = eventData.position - _lastMousePosition; if (Object.op_Implicit((Object)(object)TargetRectTransform)) { RectTransform targetRectTransform = TargetRectTransform; ((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, ((Transform)TargetRectTransform).position.z); } _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)TargetRectTransform)) { this.OnPanelEndDrag?.Invoke(this, Vector2.op_Implicit(TargetRectTransform.anchoredPosition)); } } } public sealed class PanelResizer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler { [CompilerGenerated] private sealed class <LerpCanvasGroupAlpha>d__10 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public PanelResizer <>4__this; public float lerpDuration; public float targetAlpha; private float <timeElapsed>5__2; private float <sourceAlpha>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LerpCanvasGroupAlpha>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; PanelResizer panelResizer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <timeElapsed>5__2 = 0f; <sourceAlpha>5__3 = panelResizer._canvasGroup.alpha; break; case 1: <>1__state = -1; break; } if (<timeElapsed>5__2 < lerpDuration) { float num2 = <timeElapsed>5__2 / lerpDuration; num2 = num2 * num2 * (3f - 2f * num2); panelResizer._canvasGroup.SetAlpha(Mathf.Lerp(<sourceAlpha>5__3, targetAlpha, num2)); <timeElapsed>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } panelResizer._canvasGroup.SetAlpha(targetAlpha); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private CanvasGroup _canvasGroup; private float _targetAlpha; private Vector2 _lastMousePosition; private Coroutine _lerpAlphaCoroutine; public RectTransform TargetRectTransform; public event EventHandler<Vector2> OnPanelEndResize; private void Awake() { _canvasGroup = ((Component)this).GetComponent<CanvasGroup>(); } private void SetCanvasGroupAlpha(float alpha) { if (_lerpAlphaCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_lerpAlphaCoroutine); _lerpAlphaCoroutine = null; } if (_canvasGroup.alpha != alpha) { _lerpAlphaCoroutine = ((MonoBehaviour)this).StartCoroutine(LerpCanvasGroupAlpha(alpha, 0.25f)); } } [IteratorStateMachine(typeof(<LerpCanvasGroupAlpha>d__10))] private IEnumerator LerpCanvasGroupAlpha(float targetAlpha, float lerpDuration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LerpCanvasGroupAlpha>d__10(0) { <>4__this = this, targetAlpha = targetAlpha, lerpDuration = lerpDuration }; } public void OnPointerEnter(PointerEventData eventData) { _targetAlpha = 1f; SetCanvasGroupAlpha(_targetAlpha); } public void OnPointerExit(PointerEventData eventData) { _targetAlpha = 0f; if (!eventData.dragging) { SetCanvasGroupAlpha(_targetAlpha); } } public void OnBeginDrag(PointerEventData eventData) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) SetCanvasGroupAlpha(1f); _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0026: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Vector2 val = _lastMousePosition - eventData.position; if (Object.op_Implicit((Object)(object)TargetRectTransform)) { RectTransform targetRectTransform = TargetRectTransform; targetRectTransform.anchoredPosition += new Vector2(0f, -0.5f * val.y); RectTransform targetRectTransform2 = TargetRectTransform; targetRectTransform2.sizeDelta += new Vector2(-1f * val.x, val.y); } SetCanvasGroupAlpha(1f); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) SetCanvasGroupAlpha(_targetAlpha); this.OnPanelEndResize?.Invoke(this, TargetRectTransform.sizeDelta); } } public sealed class ParentSizeFitter : MonoBehaviour { private RectTransform _parentRectTransform; private RectTransform _rectTransform; private void Awake() { _parentRectTransform = ((Component)((Component)this).transform.parent).GetComponent<RectTransform>(); _rectTransform = ((Component)this).GetComponent<RectTransform>(); } private void OnRectTransformDimensionsChange() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_parentRectTransform)) { _parentRectTransform = ((Component)((Component)this).transform.parent).GetComponent<RectTransform>(); } if (!Object.op_Implicit((Object)(object)_rectTransform)) { _rectTransform = ((Component)this).GetComponent<RectTransform>(); } if (Object.op_Implicit((Object)(object)_rectTransform) && Object.op_Implicit((Object)(object)_parentRectTransform)) { _rectTransform.SetSizeWithCurrentAnchors((Axis)0, _parentRectTransform.sizeDelta.x); } } } public sealed class PointerState : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public bool IsPointerHovered { get; private set; } public void OnPointerEnter(PointerEventData eventData) { IsPointerHovered = true; } public void OnPointerExit(PointerEventData eventData) { IsPointerHovered = false; } } public static class UIBuilder { private static readonly Lazy<TextGenerator> CachedTextGenerator = new Lazy<TextGenerator>(); private static readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>(); private static readonly Color32 ColorWhite = Color32.op_Implicit(Color.white); private static readonly Color32 ColorClear = Color32.op_Implicit(Color.clear); public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).text = string.Empty; ((TMP_Text)obj).fontSize = 16f; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).richText = true; ((TMP_Text)obj).enableAutoSizing = false; return obj; } public static GameObject CreateRowSpacer(Transform parentTransform) { //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) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown GameObject val = new GameObject(((Object)parentTransform).name + ".Spacer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<LayoutElement>().SetPreferred(20f, null); return val; } public static float GetPreferredWidth(this Text text) { return GetPreferredWidth(text, text.text); } public static float GetPreferredWidth(Text text, string content) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) TextGenerator value = CachedTextGenerator.Value; Rect rect = ((Graphic)text).rectTransform.rect; return value.GetPreferredWidth(content, text.GetGenerationSettings(((Rect)(ref rect)).size)); } public static Sprite CreateRoundedCornerSprite(int width, int height, int radius, FilterMode filterMode = 1) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b7: 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_0071: 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_00d8: 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_00e2: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) string text = $"RoundedCorner-{width}w-{height}h-{radius}r"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode(filterMode); Color32[] array = (Color32[])(object)new Color32[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { array[i * width + j] = (IsCornerPixel(j, i, width, height, radius) ? ColorClear : ColorWhite); } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text); _spriteCache[text] = value; return value; } private static bool IsCornerPixel(int x, int y, int w, int h, int rad) { if (rad == 0) { return false; } int num = Math.Min(x, w - x); int num2 = Math.Min(y, h - y); if (num == 0 && num2 == 0) { return true; } if (num > rad || num2 > rad) { return false; } num = rad - num; num2 = rad - num2; return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad; } public static Sprite CreateSuperellipse(int width, int height, float exponent) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) string text = $"Superellipse-{width}w-{height}h-{exponent}e"; if (_spriteCache.TryGetValue(text, out var value)) { return value; } Texture2D val = Texture2DExtensions.SetName(new Texture2D(width, height), text).SetWrapMode((TextureWrapMode)1).SetFilterMode((FilterMode)2); Color32[] array = (Color32[])(object)new Color32[width * height]; int num = width / 2; int num2 = height / 2; float num3 = 1f * ((float)width / 2f); float num4 = 1f * ((float)height / 2f); for (int i = 0; i < num; i++) { for (int j = 0; j < num2; j++) { Color32 val2 = Color32.op_Implicit((Mathf.Pow(Mathf.Abs((float)i / num3), exponent) + Mathf.Pow(Mathf.Abs((float)j / num4), exponent) > 1f) ? Color.clear : Color.white); int x2 = i + num; int x3 = -i + num - 1; int y2 = -j + num2 - 1; int y3 = j + num2; array[XYToIndex(x2, y3)] = val2; array[XYToIndex(x2, y2)] = val2; array[XYToIndex(x3, y2)] = val2; array[XYToIndex(x3, y3)] = val2; } } val.SetPixels32(array); val.Apply(); int k; for (k = 0; k < width && !(Color32.op_Implicit(array[k]) == Color.white); k++) { } int l; for (l = 0; l < height && !(Color32.op_Implicit(array[l * width]) == Color.white); l++) { } value = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)k, (float)l, (float)k, (float)l)).SetName(text); _spriteCache[text] = value; return value; int XYToIndex(int x, int y) { return x + y * width; } } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class GameObjectExtensions { public static GameObject SetName(this GameObject gameObject, string name) { ((Object)gameObject).name = name; return gameObject; } public static T SetName<T>(this T component, string name) where T : Component { ((Object)((Component)component).gameObject).name = name; return component; } public static GameObject SetParent(this GameObject gameObject, Transform transform, bool worldPositionStays = false) { gameObject.transform.SetParent(transform, worldPositionStays); return gameObject; } public static IEnumerable<GameObject> Children(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return Array.Empty<GameObject>(); } return from Transform t in (IEnumerable)gameObject.transform select ((Component)t).gameObject; } public static Button Button(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<Button>(); } public static Image Image(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<Image>(); } public static LayoutElement LayoutElement(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<LayoutElement>(); } public static RectTransform RectTransform(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<RectTransform>(); } public static Text Text(this GameObject gameObject) { if (!Object.op_Implicit((Object)(object)gameObject)) { return null; } return gameObject.GetComponent<Text>(); } } public static class GridLayoutGroupExtensions { public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.cellSize = cellSize; return layoutGroup; } public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.constraint = constraint; return layoutGroup; } public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount) { layoutGroup.constraintCount = constraintCount; return layoutGroup; } public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startAxis = startAxis; return layoutGroup; } public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startCorner = startCorner; return layoutGroup; } public static GridLayoutGroup SetPadding(this GridLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.spacing = spacing; return layoutGroup; } } public static class HorizontalLayoutGroupExtensions { public static HorizontalLayoutGroup SetChildControl(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetChildForceExpand(this HorizontalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetChildAlignment(this HorizontalLayoutGroup layoutGroup, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static HorizontalLayoutGroup SetPadding(this HorizontalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static HorizontalLayoutGroup SetSpacing(this HorizontalLayoutGroup layoutGroup, float spacing) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class InputFieldExtensions { public static InputField SetTextComponent(this InputField inputField, Text textComponent) { inputField.textComponent = textComponent; return inputField; } } public static class LayoutElementExtensions { public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } public static LayoutElement SetPreferred(this LayoutElement layoutElement, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) layoutElement.preferredWidth = sizeDelta.x; layoutElement.preferredHeight = sizeDelta.y; return layoutElement; } public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } } public static class MaskExtensions { public static Mask SetShowMaskGraphic(this Mask mask, bool showMaskGraphic) { mask.showMaskGraphic = showMaskGraphic; return mask; } } public static class OutlineExtensions { public static Outline SetEffectColor(this Outline outline, Color effectColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Shadow)outline).effectColor = effectColor; return outline; } public static Outline SetEffectDistance(this Outline outline, Vector2 effectDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Shadow)outline).effectDistance = effectDistance; return outline; } public static Outline SetUseGraphicAlpha(this Outline outline, bool useGraphicAlpha) { ((Shadow)outline).useGraphicAlpha = useGraphicAlpha; return outline; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class SelectableExtensions { public static Selectable SetColors(this Selectable selectable, ColorBlock colors) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) selectable.colors = colors; return selectable; } public static Selectable SetImage(this Selectable selectable, Image image) { selectable.image = image; return selectable; } public static Selectable SetInteractable(this Selectable selectable, bool interactable) { selectable.interactable = interactable; return selectable; } public static Selectable SetTargetGraphic(this Selectable selectable, Graphic graphic) { selectable.targetGraphic = graphic; return selectable; } public static Selectable SetTransition(this Selectable selectable, Transition transition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) selectable.transition = transition; return selectable; } public static Selectable SetNavigationMode(this Selectable selectable, Mode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = selectable.navigation; ((Navigation)(ref navigation)).mode = mode; selectable.navigation = navigation; return selectable; } } public static class ShadowExtensions { public static Shadow SetEffectColor(this Shadow shadow, Color effectColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectColor = effectColor; return shadow; } public static Shadow SetEffectDistance(this Shadow shadow, Vector2 effectDistance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) shadow.effectDistance = effectDistance; return shadow; } } public static class ScrollRectExtensions { public static ScrollRect SetScrollSensitivity(this ScrollRect scrollRect, float sensitivity) { scrollRect.scrollSensitivity = sensitivity; return scrollRect; } public static ScrollRect SetVerticalScrollPosition(this ScrollRect scrollRect, float position) { scrollRect.verticalNormalizedPosition = position; return scrollRect; } public static ScrollRect SetViewport(this ScrollRect scrollRect, RectTransform viewport) { scrollRect.viewport = viewport; return scrollRect; } public static ScrollRect SetContent(this ScrollRect scrollRect, RectTransform content) { scrollRect.content = content; return scrollRect; } public static ScrollRect SetHorizontal(this ScrollRect scrollRect, bool horizontal) { scrollRect.horizontal = horizontal; return scrollRect; } public static ScrollRect SetVertical(this ScrollRect scrollRect, bool vertical) { scrollRect.vertical = vertical; return scrollRect; } } public static class SpriteExtensions { public static Sprite SetName(this Sprite sprite, string name) { ((Object)sprite).name = name; return sprite; } } public static class TextExtensions { public static Text SetAlignment(this Text text, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) text.alignment = alignment; return text; } public static Text SetColor(this Text text, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)text).color = color; return text; } public static Text SetFont(this Text text, Font font) { text.font = font; return text; } public static Text SetFontStyle(this Text text, FontStyle fontStyle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) text.fontStyle = fontStyle; return text; } public static Text SetFontSize(this Text text, int fontSize) { text.fontSize = fontSize; return text; } public static Text SetResizeTextForBestFit(this Text text, bool resizeTextForBestFit) { text.resizeTextForBestFit = resizeTextForBestFit; return text; } public static Text SetSupportRichText(this Text text, bool supportRichText) { text.supportRichText = supportRichText; return text; } public static Text SetText(this Text text, string value) { text.text = value; return text; } } public static class TMPTextExtensions { public static TMP_Text SetText(this TMP_Text text, string value) { text.text = value; return text; } } public static class Texture2DExtensions { public static Texture2D SetName(this Texture2D texture, string name) { ((Object)texture).name = name; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } } public static class VerticalLayoutGroupExtensions { public static VerticalLayoutGroup SetChildControl(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static VerticalLayoutGroup SetChildForceExpand(this VerticalLayoutGroup layoutGroup, bool? width = null, bool? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static VerticalLayoutGroup SetChildAlignment(this VerticalLayoutGroup layoutGroup, TextAnchor alignment) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static VerticalLayoutGroup SetPadding(this VerticalLayoutGroup layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static VerticalLayoutGroup SetSpacing(this VerticalLayoutGroup layoutGroup, float spacing) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ButtonExtensions { public static Button SetOnClickListener(this Button button, UnityAction action) { ((UnityEvent)button.onClick).AddListener(action); return button; } } public static class UIResources { private static readonly Dictionary<string, Sprite> SpriteCache = new Dictionary<string, Sprite>(); public static string ValheimNorseFont = "Valheim-Norse"; public static string ValheimAveriaSansLibre = "Valheim-AveriaSansLibre"; public static Dictionary<string, TMP_FontAsset> FontAssetCache { get; private set; } = new Dictionary<string, TMP_FontAsset>(); public static TMP_FontAsset ValheimNorseFontAsset => ((TMP_Text)Minimap.m_instance.m_pinNamePrefab.GetComponentInChildren<TextMeshProUGUI>()).font; public static TMP_FontAsset ValheimAveriaSansLibreFontAsset => ((TMP_Text)UnifiedPopup.instance.bodyText).font; public static Sprite GetSprite(string spriteName) { if (!SpriteCache.TryGetValue(spriteName, out var value)) { value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite sprite) => ((Object)sprite).name == spriteName)); SpriteCache[spriteName] = value; } return value; } public static TMP_FontAsset GetFontAssetByName(string fontAssetName) { if (FontAssetCache.TryGetValue(fontAssetName, out var value)) { return value; } if (fontAssetName == ValheimNorseFont) { value = ValheimNorseFontAsset; FontAssetCache[fontAssetName] = value; return value; } if (fontAssetName == ValheimAveriaSansLibre) { value = ValheimAveriaSansLibreFontAsset; FontAssetCache[fontAssetName] = value; return value; } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); foreach (TMP_FontAsset val in array) { FontAssetCache[((Object)val).name] = val; } return FontAssetCache[fontAssetName]; } } public sealed class PlayerListRow { private long _pid; private static readonly Lazy<ColorBlock> ButtonColorBlock = new Lazy<ColorBlock>((Func<ColorBlock>)delegate { //IL_0002: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) ColorBlock result = default(ColorBlock); ((ColorBlock)(ref result)).normalColor = new Color(0f, 0f, 0f, 0.01f); ((ColorBlock)(ref result)).highlightedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)128)); ((ColorBlock)(ref result)).disabledColor = new Color(0f, 0f, 0f, 0.1f); ((ColorBlock)(ref result)).pressedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)192)); ((ColorBlock)(ref result)).selectedColor = Color32.op_Implicit(new Color32((byte)50, (byte)161, (byte)217, (byte)248)); ((ColorBlock)(ref result)).colorMultiplier = 1f; ((ColorBlock)(ref result)).fadeDuration = 0f; return result; }); public GameObject Row { get; private set; } public Image PinIcon { get; private set; } public TMP_Text PinName { get; private set; } public TMP_Text PinCount { get; private set; } public TMP_Text FilterStatus { get; private set; } public PlayerListRow(Transform parentTransform) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) Row = CreateChildRow(parentTransform); PinIcon = CreateChildPinIcon(Row.transform).Image(); PinName = CreateChildPinName(Row.transform); UIBuilder.CreateRowSpacer(Row.transform); PinCount = CreatePinCountValue(Row.transform); ((Graphic)PinCount).color = new Color(0.565f, 0.792f, 0.976f); FilterStatus = CreatePinCountValue(Row.transform); FilterStatus.fontSize = 14f; } public PlayerListRow SetRowContent(long pid) { _pid = pid; PinIcon.SetSprite(Minimap.m_instance.GetSprite((PinType)10)); UpdateName(); UpdateCount(); UpdateFilterStatus(); return this; } public void UpdateName() { PinName.SetText(NameManager.GetPlayerNameById(_pid)); } public void UpdateCount() { PinCount.SetText($"{PinOwnerManager.GetPinsByPid(_pid).Count}"); } public void UpdateFilterStatus() { if (PinOwnerManager.IsFiltered(_pid)) { FilterStatus.SetText("<color=red>X</color>"); } else { FilterStatus.SetText("<color=green><b>✓</b></color>"); } } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("PinList.Row", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetChildAlignment((TextAnchor)4) .SetPadding(5, 10, 5, 5) .SetSpacing(5f); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(400, 400, 5, (FilterMode)1)); ((Selectable)(object)val.AddComponent<Button>().SetOnClickListener(new UnityAction(ToggleFilter))).SetNavigationMode((Mode)0).SetTargetGraphic((Graphic)(object)val.Image()).SetColors(ButtonColorBlock.Value); val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2); val.AddComponent<ParentSizeFitter>(); return val; } public void ToggleFilter() { PinOwnerManager.ToggleFilter(_pid); UpdateFilterStatus(); } private GameObject CreateChildPinIcon(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: 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_0054: Expected O, but got Unknown GameObject val = new GameObject("Pin.Icon", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<LayoutElement>().SetPreferred(20f, 20f); val.AddComponent<Image>().SetType((Type)0); return val; } private TMP_Text CreateChildPinName(Transform parentTransform) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) TMP_Text val = (TMP_Text)(object)UIBuilder.CreateTMPLabel(parentTransform); val.SetName<TMP_Text>("Pin.Name"); val.alignment = (TextAlignmentOptions)513; val.text = "Blankname1234567891011121314"; ((Component)val).gameObject.AddComponent<LayoutElement>().SetPreferred(val.GetPreferredValues().x, null); return val; } private TMP_Text CreatePinCountValue(Transform parentTransform) { //IL_0035: 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) TMP_Text val = (TMP_Text)(object)UIBuilder.CreateTMPLabel(parentTransform); val.SetName<TMP_Text>("Pin.Count.Value"); val.alignment = (TextAlignmentOptions)516; val.text = "-12X✓"; ((Component)val).gameObject.AddComponent<LayoutElement>().SetPreferred(val.GetPreferredValues().x, val.GetPreferredValues().y); return val; } } public sealed class PlayerPinFilterPanel { private readonly PointerState _pointerState; private readonly List<PlayerListRow> _rowCache = new List<PlayerListRow>(); private int _visibleRows; private float _rowPreferredHeight; private LayoutElement _bufferBlock; public GameObject Panel { get; private set; } public ValueCell PinNameFilter { get; private set; } public GameObject Viewport { get; private set; } public GameObject Content { get; private set; } public ScrollRect ScrollRect { get; private set; } public LabelCell PinStats { get; private set; } public PanelDragger PanelDragger { get; private set; } public PanelResizer PanelResizer { get; private set; } public PlayerPinFilterPanel(Transform parentTransform) { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) Panel = CreateChildPanel(parentTransform); PanelDragger = CreateChildPanelDragger(Panel).AddComponent<PanelDragger>(); PanelDragger.TargetRectTransform = Panel.RectTransform(); PanelResizer = CreateChildPanelResizer(Panel).AddComponent<PanelResizer>(); PanelResizer.TargetRectTransform = Panel.RectTransform(); PinNameFilter = new ValueCell(Panel.transform); LayoutElement layoutElement = PinNameFilter.Cell.LayoutElement().SetFlexible(1f); float? height = 30f; layoutElement.SetPreferred(null, height); Viewport = CreateChildViewport(Panel.transform); Content = CreateChildContent(Viewport.transform); ScrollRect = CreateChildScrollRect(Panel, Viewport, Content); PinStats = new LabelCell(Panel.transform); PinStats.Cell.GetComponent<HorizontalLayoutGroup>().SetPadding(8, 8, 5, 5); PinStats.Cell.Image().SetColor(new Color(0.5f, 0.5f, 0.5f, 0.1f)); PinStats.Cell.AddComponent<Outline>().SetEffectDistance(new Vector2(2f, -2f)); _pointerState = Panel.AddComponent<PointerState>(); UpdatePanel(); } public bool HasFocus() { if (Object.op_Implicit((Object)(object)Panel) && Panel.activeInHierarchy) { return _pointerState.IsPointerHovered; } return false; } public void UpdatePinCounts() { if ((Object)(object)Panel == (Object)null) { return; } foreach (PlayerListRow item in _rowCache) { item.UpdateCount(); } } public void UpdatePanel() { RefreshPinListRows(); PinStats.Label.SetText($"{PinOwnerManager.ForeignPinOwners.Count} players with pins."); } private void BuildPinListRows() { } private void RefreshPinListRows() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) ((UnityEventBase)ScrollRect.onValueChanged).RemoveAllListeners(); Content.RectTransform().SetPosition(Vector2.zero); ScrollRect.SetVerticalScrollPosition(1f); _rowCache.Clear(); foreach (GameObject item in Content.Children()) { Object.Destroy((Object)(object)item); } GameObject val = new GameObject("ppl.Block", new Type[1] { typeof(RectTransform) }); val.SetParent(Content.transform); _bufferBlock = val.AddComponent<LayoutElement>(); LayoutElement bufferBlock = _bufferBlock; float? height = 0f; bufferBlock.SetPreferred(null, height); PlayerListRow playerListRow = new PlayerListRow(Content.transform); LayoutRebuilder.ForceRebuildLayoutImmediate(Panel.RectTransform()); _rowPreferredHeight = LayoutUtility.GetPreferredHeight(playerListRow.Row.RectTransform()); _visibleRows = Mathf.CeilToInt(Viewport.RectTransform().sizeDelta.y / _rowPreferredHeight); Object.Destroy((Object)(object)playerListRow.Row); Content.RectTransform().SetSizeDelta(new Vector2(Viewport.RectTransform().sizeDelta.x, _rowPreferredHeight * (float)PinOwnerManager.ForeignPinOwners.Count)); PinOwnerManager.SortPinOwnersByName(); for (int i = 0; i < PinOwnerManager.ForeignPinOwners.Count; i++) { playerListRow = new PlayerListRow(Content.transform); playerListRow.SetRowContent(PinOwnerManager.GetForeignPinOwnerAtIndex(i)); _rowCache.Add(playerListRow); } ScrollRect.SetVerticalScrollPosition(1f); } private GameObject CreateChildPanel(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown GameObject val = new GameObject("PlayerPinList.Panel", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(8, 8, 8, 8) .SetSpacing(8f); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateSuperellipse(400, 400, 15f)) .SetColor(new Color(0f, 0f, 0f, 0.9f)); return val; } private GameObject CreateChildViewport(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0083: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown GameObject val = new GameObject("PlayerPinList.Viewport", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<RectMask2D>(); val.AddComponent<LayoutElement>().SetFlexible(1f, 1f); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(128, 128, 8, (FilterMode)1)) .SetColor(new Color(0.5f, 0.5f, 0.5f, 0.1f)); val.AddComponent<Outline>().SetEffectDistance(new Vector2(2f, -2f)); return val; } private GameObject CreateChildContent(Transform parentTransform) { //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_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: 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_0040: 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_007e: 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_0096: Expected O, but got Unknown GameObject val = new GameObject("PlayerPinList.Content", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.up) .SetPivot(Vector2.up); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetSpacing(0f); val.AddComponent<Image>().SetColor(Color.clear).SetRaycastTarget(raycastTarget: true); return val; } private ScrollRect CreateChildScrollRect(GameObject panel, GameObject viewport, GameObject content) { return panel.AddComponent<ScrollRect>().SetViewport(viewport.RectTransform()).SetContent(content.RectTransform()) .SetHorizontal(horizontal: false) .SetVertical(vertical: true) .SetScrollSensitivity(30f); } private GameObject CreateChildPanelDragger(GameObject panel) { //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_002a: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003e: 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) //IL_005c: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown GameObject val = new GameObject("ppl.Dragger", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, panel.transform); val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); val.AddComponent<Image>().SetColor(Color.clear); return val; } private GameObject CreateChildPanelResizer(GameObject panel) { //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_002a: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003e: 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) //IL_0052: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown GameObject val = new GameObject("ppl.Resizer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, panel.transform); val.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); GameObjectExtensions.RectTransform(val).SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right) .SetPivot(Vector2.right) .SetSizeDelta(new Vector2(40f, 40f)) .SetPosition(new Vector2(15f, -15f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(128, 128, 12, (FilterMode)1)) .SetColor(new Color(0.565f, 0.792f, 0.976f, 0.849f)); val.AddComponent<Shadow>().SetEffectDistance(new Vector2(2f, -2f)); val.AddComponent<CanvasGroup>().SetAlpha(0f); TextMeshProUGUI obj = UIBuilder.CreateTMPLabel(val.transform); ((TMP_Text)(object)obj).SetName<TMP_Text>("Resizer.Icon"); ((Component)obj).gameObject.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); ((Component)obj).gameObject.RectTransform().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 24f; ((TMP_Text)obj).text = "⇆⇅"; return val; } } [HarmonyPatch(typeof(MapTable))] internal static class MapTablePatch { private static readonly string _nameHashBase = "pintervention.pid_name"; private static readonly char _seperator = '_'; [HarmonyPrefix] [HarmonyPatch("OnRead", new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemData), typeof(bool) })] private static bool OnReadPostfix(MapTable __instance, ItemData item, ref bool __result) { if (!PluginConfig.IsModEnabled.Value || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.m_nview) || !__instance.m_nview.IsValid() || item != null) { return true; } LoadPlayerNames(__instance.m_nview.GetZDO()); if (PluginConfig.ReadRevealedMapOnInteract.Value && PluginConfig.ReadPinsOnInteract.Value) { return true; } SharedMapDataManager.ReadMapData(__instance.m_nview.GetZDO()); __result = false; return false; } [HarmonyPostfix] [HarmonyPatch("OnRead", new Type[] { typeof(Switch), typeof(Humanoid), typeof(ItemData), typeof(bool) })] private static void OnReadPostfix(MapTable __instance, ItemData item) { if (PluginConfig.ReadPinsOnInteract.Value) { PinOwnerManager.FindPinOwners(); NameManager.WriteNamesToFile(); } } [HarmonyPrefix] [HarmonyPatch("OnWrite")] private static void OnWritePrefix(MapTable __instance) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.IsValid() && Object.op_Implicit((Object)(object)Player.m_localPlayer) && ClaimOwnership(__instance) && __instance.m_nview.IsOwner()) { AddNamesToTable(__instance); SendTableZdoUpdate(__instance); } } [HarmonyPostfix] [HarmonyPatch("GetReadHoverText")] private static void GetReadHoverTextPostfix(MapTable __instance, ref string __result) { __result = Localization.instance.Localize(__instance.m_name + "\n[<color=yellow><b>$KEY_Use</b></color>]") + " Interact\n[" + GetBoolUnicodeCharacter(PluginConfig.ReadPinsOnInteract.Value) + "] Read pins\n[" + GetBoolUnicodeCharacter(PluginConfig.ReadRevealedMapOnInteract.Value) + "] Read revealed map"; } private static string GetBoolUnicodeCharacter(bool enabled) { if (enabled) { return "<color=green><b>✓</b></color>"; } return "<color=red><b>X</b></color>"; } private static void SendTableZdoUpdate(MapTable __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = __instance.m_nview.GetZDO().m_uid; foreach (ZNetPeer item in ZNet.instance.m_peers.Where((ZNetPeer x) => Player.s_players.Select((Player x) => ((Character)x).m_nview.GetZDO().m_uid).Contains(x.m_characterID)).ToList()) { ZDOMan.instance.ForceSendZDO(item.m_uid, uid); } } private static bool ClaimOwnership(MapTable table) { if (!Object.op_Implicit((Object)(object)table) || !Object.op_Implicit((Object)(object)table.m_nview) || !table.m_nview.IsValid()) { return false; } Pintervention.LogInfo("Claimed table ownership to write name data."); table.m_nview.ClaimOwnership(); return true; } private static void LoadPlayerNames(ZDO zdo) { string text = "not empty"; int num = 0; while (text != string.Empty) { text = zdo.GetString(GetNumberedHashCode(num), string.Empty); if (!(text == string.Empty)) { num++; KeyValuePair<long, string> keyValuePair = ParsePidNamePair(text); if (keyValuePair.Equals(default(KeyValuePair<long, string>))) { Pintervention.LogWarning($"Unable to parse name at index {num} with value {text}."); } else { NameManager.AddPlayerName(keyValuePair.Key, keyValuePair.Value); } } } } private static KeyValuePair<long, string> ParsePidNamePair(string storedValue) { string[] array = storedValue.Split(new char[1] { _seperator }); if (array.Length != 2 || !long.TryParse(array[0], out var result)) { return default(KeyValuePair<long, string>); } return new KeyValuePair<long, string>(result, array[1]); } private static bool IsNameOnTable(MapTable table, long pid, string name) { ZDO zDO = table.m_nview.GetZDO(); string storedValue = GetStoredValue(pid, name); int num = 0; string text = "not empty"; while (text != string.Empty) { text = zDO.GetString(GetNumberedHashCode(num), string.Empty); if (text == storedValue) { return true; } num++; } Pintervention.LogInfo("Name " + Player.m_localPlayer.GetPlayerName() + " not found on map table."); return false; } private static void AddNamesToTable(MapTable table) { Dictionary<long, string> playerNamesById = NameManager.PlayerNamesById; if (!playerNamesById.ContainsKey(Player.m_localPlayer.GetPlayerID())) { playerNamesById.Add(Player.m_localPlayer.GetPlayerID(), Player.m_localPlayer.GetPlayerName()); } foreach (KeyValuePair<long, string> item in NameManager.PlayerNamesById) { if (!IsNameOnTable(table, item.Key, item.Value) && !item.Value.StartsWith("Unknown")) { table.m_nview.GetZDO().Set(GetNextEmptyHashCode(table.m_nview.GetZDO()), GetStoredValue(item.Key, item.Value)); } } } private static string GetStoredValue(long pid, string name) { return $"{pid}{_seperator}{name}"; } private static int GetNextEmptyHashCode(ZDO zdo) { int num = 0; string text = "not empty"; while (text != string.Empty) { text = zdo.GetString(GetNumberedHashCode(num), string.Empty); if (!(text == string.Empty)) { num++; } } return GetNumberedHashCode(num); } private static int GetNumberedHashCode(int i) { return StringExtensionMethods.GetStableHashCode($"{_nameHashBase}{i}"); } } [HarmonyPatch(typeof(Minimap))] internal static class MinimapPatch { private static int _pinCount = 999999; [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(Minimap __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value && Minimap.IsOpen() && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_largeRoot)) { KeyboardShortcut value = PluginConfig.DisplayFilterPanel.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { PinOwnerManager.Initialize(); PlayerFilterPanelManager.ToggleFilterPanel(); } } } [HarmonyPostfix] [HarmonyPatch("UpdatePins")] private static void UpdatePinsPostfix(Minimap __instance) { if (PluginConfig.IsModEnabled.Value && Minimap.IsOpen() && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.m_largeRoot)) { PinOwnerManager.FilterPins(); PlayerFilterPanelManager.UpdatePinCounts(); } } [HarmonyPostfix] [HarmonyPatch("UpdatePlayerPins")] private static void UpdatePlayerPinsPostfix(Minimap __instance) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)__instance)) { Object.op_Implicit((Object)(object)Player.m_localPlayer); } if (_pinCount > __instance.m_pins.Count) { _pinCount = __instance.m_pins.Count; PinOwnerManager.AddAllLocalPlayerPins(); PlayerFilterPanelManager.UpdatePanel(); } } [HarmonyPostfix] [HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })] private static void RemovePinPostfix(Minimap __instance, PinData pin) { long ownerID = pin.m_ownerID; PinOwnerManager.RemoveLocalPlayerPin(pin); if (PinOwnerManager.GetPinsByPid(ownerID).Count == 0) { PinOwnerManager.RemoveForeignPinOwner(ownerID); } PlayerFilterPanelManager.UpdatePanel(); } [HarmonyPostfix] [HarmonyPatch("ResetSharedMapData")] private static void ResetSharedMapData(Minimap __instance) { PinOwnerManager.ForeignPinOwners.RemoveAll((long x) => PinOwnerManager.GetPinsByPid(x).Count == 0); PlayerFilterPanelManager.UpdatePanel(); } } [HarmonyPatch(typeof(ZNet))] internal static class ZNetPatch { [HarmonyPrefix] [HarmonyPatch("OnDestroy")] private static void OnDestroyPrefix() { if (PluginConfig.IsModEnabled.Value) { PinOwnerManager.WriteFilteredPlayersToFile(); PinOwnerManager.Clear(); } } } [BepInPlugin("bruce.valheim.comfymods.pintervention", "Pintervention", "1.3.0")] public sealed class Pintervention : BaseUnityPlugin { public const string PluginGuid = "bruce.valheim.comfymods.pintervention"; public const string PluginName = "Pintervention"; public const string PluginVersion = "1.3.0"; private static ManualLogSource _logger; private void Awake() { _logger = ((BaseUnityPlugin)this).Logger; PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "bruce.valheim.comfymods.pintervention"); } public static void MessageLocalPlayer(string message) { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, message, 0, (Sprite)null); } } public static void LogInfo<T>(T obj) { _logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}