Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Quads Portal Hub v1.4.3
plugins/PortalHub.dll
Decompiled 2 days 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.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using DHack.Shared; 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: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (Claude Code).")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PortalHub { internal static class GameUi { private const string CanvasName = "PortalHubCanvas"; internal static Func<bool> IsOpen = () => false; internal static TMP_FontAsset Norse; internal static TMP_FontAsset Serif; internal static TMP_FontAsset Sans; private static Image _panel; private static Image _sunken; private static Image _braid; private static Button _button; private static Button _tab; private static GameObject _cell; private static float _cellSpace = 70f; internal static readonly Color Warm = new Color(1f, 0.86f, 0.55f); internal static readonly Color Text = new Color(0.94f, 0.9f, 0.82f); internal static readonly Color Dim = new Color(0.75f, 0.72f, 0.66f); internal static readonly Color Gold = new Color(1f, 0.78f, 0.3f); internal static readonly Color Warn = new Color(1f, 0.55f, 0.35f); internal static readonly Color Good = new Color(0.6f, 0.9f, 0.55f); private static Canvas _canvas; internal static Transform Canvas { get { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown if ((Object)(object)_canvas != (Object)null) { Match(); return ((Component)_canvas).transform; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return null; } foreach (Transform item in (from Transform t in (IEnumerable)((Component)instance).transform.parent where ((Object)t).name == "PortalHubCanvas" select t).ToList()) { Object.Destroy((Object)(object)((Component)item).gameObject); } Canvas val = ((Component)instance).GetComponentInChildren<Canvas>(true) ?? ((Component)instance).GetComponentInParent<Canvas>(); GameObject val2 = new GameObject("PortalHubCanvas", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(((Component)instance).transform.parent, false); _canvas = val2.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = (((Object)(object)val != (Object)null) ? val.sortingOrder : 0) + 5; val2.AddComponent<CanvasScaler>(); val2.AddComponent<GraphicRaycaster>(); Match(); return ((Component)_canvas).transform; } } internal static float CellSpace => _cellSpace; internal static Transform HudRoot { get { if (!((Object)(object)Hud.instance != (Object)null) || !((Object)(object)Hud.instance.m_rootObject != (Object)null)) { return null; } return Hud.instance.m_rootObject.transform; } } internal static bool Typing { get { EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null); TMP_InputField val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<TMP_InputField>() : null); if ((Object)(object)val2 != (Object)null) { return val2.isFocused; } return false; } } private static void Match() { //IL_0054: 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_006c: Unknown result type (might be due to invalid IL or missing references) InventoryGui instance = InventoryGui.instance; CanvasScaler val = (((Object)(object)_canvas != (Object)null) ? ((Component)_canvas).GetComponent<CanvasScaler>() : null); CanvasScaler val2 = (((Object)(object)instance != (Object)null) ? (((Component)instance).GetComponentInChildren<CanvasScaler>(true) ?? ((Component)instance).GetComponentInParent<CanvasScaler>()) : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { val.uiScaleMode = val2.uiScaleMode; val.referenceResolution = val2.referenceResolution; val.screenMatchMode = val2.screenMatchMode; val.matchWidthOrHeight = val2.matchWidthOrHeight; val.scaleFactor = val2.scaleFactor; val.referencePixelsPerUnit = val2.referencePixelsPerUnit; } } internal static void Destroy() { if ((Object)(object)_canvas != (Object)null) { Object.Destroy((Object)(object)((Component)_canvas).gameObject); } _canvas = null; _panel = null; _button = null; _cell = null; IsOpen = () => false; } internal static bool Ready() { if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null && (Object)(object)_cell != (Object)null) { return true; } InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null) { return false; } Transform root = ((Component)instance).transform; _panel = Find<Image>("root/Crafting/Bkg") ?? Find<Image>("root/Player/Bkg"); _sunken = Find<Image>("root/Player/sunken"); _braid = Find<Image>("root/Crafting/BraidLineHorisontalMedium"); _button = Find<Button>("root/Player/Container/TakeAll"); _tab = Find<Button>("root/Crafting/TabsButtons/Craft"); TMP_Text obj = Find<TMP_Text>("root/Crafting/topic"); Norse = ((obj != null) ? obj.font : null); TMP_Text obj2 = Find<TMP_Text>("root/Crafting/TabsButtons/Craft/Text"); Serif = ((obj2 != null) ? obj2.font : null); TMP_Text obj3 = Find<TMP_Text>("root/Crafting/Decription/Description"); Sans = ((obj3 != null) ? obj3.font : null) ?? Serif; InventoryGrid playerGrid = instance.m_playerGrid; if ((Object)(object)playerGrid != (Object)null) { _cell = playerGrid.m_elementPrefab; _cellSpace = ((playerGrid.m_elementSpace > 1f) ? playerGrid.m_elementSpace : 70f); } if ((Object)(object)_button == (Object)null || (Object)(object)_panel == (Object)null || (Object)(object)_cell == (Object)null) { Debug.LogWarning((object)"PortalHubCanvas: the game's interface was not found where expected (a game update moved it?)"); } if ((Object)(object)_button != (Object)null && (Object)(object)_panel != (Object)null) { return (Object)(object)_cell != (Object)null; } return false; T Find<T>(string path) where T : Component { Transform val = root.Find(path); if (!((Object)(object)val != (Object)null)) { return default(T); } return ((Component)val).GetComponent<T>(); } } internal static RectTransform Rect(Transform parent, string name, Vector2 anchor, Vector2 pivot, Vector2 pos, Vector2 size) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0030: 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_0032: 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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(parent, false); Vector2 anchorMin = (val2.anchorMax = anchor); val2.anchorMin = anchorMin; val2.pivot = pivot; val2.anchoredPosition = pos; val2.sizeDelta = size; return val2; } internal static RectTransform Window(string name, Vector2 size) { //IL_0010: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(Canvas, name, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, size); Copy(_panel, ((Component)val).gameObject.AddComponent<Image>()); return val; } internal static RectTransform Box(Transform parent, Vector2 pos, Vector2 size) { //IL_0010: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(parent, "Box", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); if ((Object)(object)_sunken != (Object)null) { Copy(_sunken, val2); } else { ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.35f); } return val; } internal static void Braid(Transform parent, Vector2 pos, float width) { //IL_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_braid == (Object)null)) { Vector2 anchor = new Vector2(0.5f, 1f); Vector2 pivot = new Vector2(0.5f, 0.5f); Rect rect = ((Graphic)_braid).rectTransform.rect; float num; if (!(((Rect)(ref rect)).height > 1f)) { num = 16f; } else { rect = ((Graphic)_braid).rectTransform.rect; num = ((Rect)(ref rect)).height; } RectTransform val = Rect(parent, "Braid", anchor, pivot, pos, new Vector2(width, num)); Copy(_braid, ((Component)val).gameObject.AddComponent<Image>()); } } private static void Copy(Image from, Image to) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)from == (Object)null)) { to.sprite = from.sprite; to.type = from.type; ((Graphic)to).material = ((Graphic)from).material; ((Graphic)to).color = ((Graphic)from).color; to.pixelsPerUnitMultiplier = from.pixelsPerUnitMultiplier; to.fillCenter = from.fillCenter; } } internal static TMP_Text Label(Transform parent, string text, Vector2 pos, Vector2 size, float fontSize, Color color, TMP_FontAsset font = null, TextAlignmentOptions align = (TextAlignmentOptions)257, Vector2? anchor = null) { //IL_0020: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Vector2 val = (Vector2)(((??)anchor) ?? new Vector2(0f, 1f)); RectTransform val2 = Rect(parent, "Text", val, val, pos, size); bool activeSelf = ((Component)val2).gameObject.activeSelf; ((Component)val2).gameObject.SetActive(false); TextMeshProUGUI val3 = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val3).font = font ?? Sans; ((Component)val2).gameObject.SetActive(activeSelf); ((TMP_Text)val3).fontSize = fontSize; ((Graphic)val3).color = color; ((TMP_Text)val3).alignment = align; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).enableWordWrapping = true; ((TMP_Text)val3).overflowMode = (TextOverflowModes)0; ((TMP_Text)val3).text = text; ((Graphic)val3).raycastTarget = false; return (TMP_Text)(object)val3; } internal static Button Button(Transform parent, string text, Vector2 pos, Vector2 size, Action click, bool enabled = true, float fontSize = 18f) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Button val = Clone(_button, parent, text, pos, size, fontSize); ((Selectable)val).interactable = enabled; ((Graphic)Label(val)).color = (enabled ? Text : Dim); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); }); return val; } internal static Button Tab(Transform parent, string text, Vector2 pos, Vector2 size, bool chosen, Action click, float fontSize = 18f) { //IL_001e: 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) //IL_006a: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown Button val = Clone(_tab ?? _button, parent, text, pos, size, fontSize); Transform val2 = ((Component)val).transform.Find("Selected"); if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(false); } ((Selectable)val).interactable = !chosen; ((Graphic)Label(val)).color = (chosen ? Gold : Text); ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { click(); }); return val; } internal static TMP_Text Label(Button b) { return ((IEnumerable<TMP_Text>)((Component)b).GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Component)t).gameObject.activeSelf)); } private static Button Clone(Button template, Transform parent, string text, Vector2 pos, Vector2 size, float fontSize) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); ((Object)val).name = "Button"; val.SetActive(true); foreach (Transform item in ((IEnumerable)val.transform).Cast<Transform>().ToList()) { if (((Object)item).name.StartsWith("gamepad_hint")) { Object.Destroy((Object)(object)((Component)item).gameObject); } } UIGamePad[] componentsInChildren = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val2 in componentsInChildren) { Object.Destroy((Object)(object)val2); } ButtonTextColor[] componentsInChildren2 = val.GetComponentsInChildren<ButtonTextColor>(true); foreach (ButtonTextColor val3 in componentsInChildren2) { Object.Destroy((Object)(object)val3); } RectTransform val4 = (RectTransform)val.transform; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.anchoredPosition = pos; val4.sizeDelta = size; Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); TMP_Text val6 = ((IEnumerable<TMP_Text>)val.GetComponentsInChildren<TMP_Text>(true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => ((Object)t).name == "Text")); if ((Object)(object)val6 == (Object)null) { val6 = Label(val.transform, text, Vector2.zero, size, fontSize, Text, Serif, (TextAlignmentOptions)514, (Vector2?)new Vector2(0.5f, 0.5f)); ((RectTransform)val6.transform).pivot = new Vector2(0.5f, 0.5f); } val6.text = text; val6.fontSize = fontSize; val6.enableAutoSizing = false; val6.enableWordWrapping = false; val6.overflowMode = (TextOverflowModes)1; RectTransform val7 = (RectTransform)val6.transform; val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = new Vector2(4f, 0f); val7.offsetMax = new Vector2(-4f, 0f); val6.alignment = (TextAlignmentOptions)514; TMP_Text[] componentsInChildren3 = val.GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val8 in componentsInChildren3) { if ((Object)(object)val8 != (Object)(object)val6) { ((Component)val8).gameObject.SetActive(false); } } return component; } internal static Image Icon(Transform parent, Vector2 pos, Vector2 size, Sprite sprite) { //IL_0010: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)Rect(parent, "Icon", new Vector2(0f, 1f), new Vector2(0f, 1f), pos, size)).gameObject.AddComponent<Image>(); val.sprite = sprite; val.preserveAspect = true; ((Graphic)val).raycastTarget = false; ((Behaviour)val).enabled = (Object)(object)sprite != (Object)null; return val; } internal static float Chip(Transform parent, Vector2 pos, ItemData item, string amount, float size = 28f, float fontSize = 17f) { //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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_007f: 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) Image val = Icon(parent, pos, new Vector2(size, size), item.GetIcon()); ((Graphic)val).raycastTarget = true; UITooltip val2 = ((!((Object)(object)_cell != (Object)null)) ? null : _cell.GetComponent<InventoryElement>()?.m_tooltip); if ((Object)(object)val2 != (Object)null) { UITooltip val3 = ((Component)val).gameObject.AddComponent<UITooltip>(); val3.m_tooltipPrefab = val2.m_tooltipPrefab; val3.Set(item.m_shared.m_name, item.GetTooltip(-1), (RectTransform)null, default(Vector2)); } TMP_Text val4 = Label(parent, amount, new Vector2(pos.x + size + 3f, pos.y - (size - fontSize * 1.3f) / 2f), new Vector2(80f, size), fontSize, Text, null, (TextAlignmentOptions)257); val4.enableWordWrapping = false; float x = val4.GetPreferredValues(amount, 200f, 0f).x; ((RectTransform)val4.transform).sizeDelta = new Vector2(x + 2f, size); return size + 3f + x + 12f; } internal static RectTransform Bar(Transform parent, Vector2 pos, Vector2 size, float fraction, Color fill, string text, float fontSize = 15f) { //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) //IL_0019: 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_0037: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) //IL_0123: 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_012a: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Box(parent, pos, size); RectTransform val2 = Rect((Transform)(object)val, "Fill", new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(2f, 2f), new Vector2(0f, 0f)); val2.anchorMax = new Vector2(0f, 1f); val2.offsetMax = new Vector2(2f + (size.x - 4f) * Mathf.Clamp01(fraction), -2f); Image val3 = ((Component)val2).gameObject.AddComponent<Image>(); ((Graphic)val3).color = new Color(fill.r * 0.8f, fill.g * 0.8f, fill.b * 0.8f, 0.9f); ((Graphic)val3).raycastTarget = false; if (!string.IsNullOrEmpty(text)) { bool[] array = new bool[2] { true, false }; foreach (bool flag in array) { TMP_Text val4 = Label((Transform)(object)val, text, new Vector2(flag ? 1f : 0f, flag ? (-1f) : 0f), size, fontSize, (Color)(flag ? new Color(0f, 0f, 0f, 0.85f) : Color.white), Sans, (TextAlignmentOptions)514); val4.enableWordWrapping = false; } } return val; } internal static InventoryElement Cell(Transform parent, Vector2 pos, ItemData item, string amount, bool selected, Action click) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(_cell, parent, false); ((Object)val).name = "Cell"; val.SetActive(true); UIDragHandler[] componentsInChildren = val.GetComponentsInChildren<UIDragHandler>(true); foreach (UIDragHandler val2 in componentsInChildren) { Object.Destroy((Object)(object)val2); } UIGamePad[] componentsInChildren2 = val.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val3 in componentsInChildren2) { Object.Destroy((Object)(object)val3); } RectTransform val4 = (RectTransform)val.transform; Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(0f, 1f); val4.anchorMax = val5; val4.anchorMin = val5; val4.pivot = new Vector2(0f, 1f); val4.anchoredPosition = pos; InventoryElement component = val.GetComponent<InventoryElement>(); component.Initialize(0, 0); Transform val6 = val.transform.Find("binding"); if ((Object)(object)val6 != (Object)null) { TMP_Text component2 = ((Component)val6).GetComponent<TMP_Text>(); if (component2 != null) { ((Behaviour)component2).enabled = false; } } ((Behaviour)component.m_icon).enabled = true; component.m_icon.sprite = item.GetIcon(); ((Graphic)component.m_icon).color = Color.white; bool flag = item.m_shared.m_useDurability && item.m_durability < item.GetMaxDurability(); ((Component)component.m_durability).gameObject.SetActive(flag); if (flag) { component.m_durability.SetValue(item.GetDurabilityPercentage()); } ((Behaviour)component.m_equiped).enabled = item.m_equipped; ((Behaviour)component.m_queued).enabled = false; ((Behaviour)component.m_noteleport).enabled = false; ((Behaviour)component.m_food).enabled = false; ((Behaviour)component.m_quality).enabled = amount == null && item.m_shared.m_maxQuality > 1; if (((Behaviour)component.m_quality).enabled) { component.m_quality.text = item.m_quality.ToString(); } ((Behaviour)component.m_amount).enabled = amount != null || item.m_shared.m_maxStackSize > 1; component.m_amount.text = amount ?? $"{item.m_stack}/{item.m_shared.m_maxStackSize}"; if ((Object)(object)component.m_selected != (Object)null) { component.m_selected.SetActive(selected); } UITooltip tooltip = component.m_tooltip; string name = item.m_shared.m_name; string tooltip2 = item.GetTooltip(-1); val5 = default(Vector2); tooltip.Set(name, tooltip2, (RectTransform)null, val5); UIInputHandler componentInChildren = val.GetComponentInChildren<UIInputHandler>(true); if ((Object)(object)componentInChildren != (Object)null && click != null) { componentInChildren.m_onLeftClick = delegate { click(); }; } return component; } internal static RectTransform Scroll(RectTransform box, float inset) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0140: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown InventoryGui gui = InventoryGui.instance; ScrollRect val = (((Object)(object)gui != (Object)null) ? ((IEnumerable<ScrollRect>)((Component)gui).GetComponentsInChildren<ScrollRect>(true)).FirstOrDefault((Func<ScrollRect, bool>)((ScrollRect s) => (Object)(object)s.content == (Object)(object)gui.m_recipeListRoot)) : null); Scrollbar val2 = (((Object)(object)gui != (Object)null) ? gui.m_recipeListScroll : null); float num; if (!((Object)(object)val2 != (Object)null)) { num = 0f; } else { Rect rect = ((RectTransform)((Component)val2).transform).rect; num = Mathf.Max(8f, ((Rect)(ref rect)).width); } float num2 = num; RectTransform val3 = Rect((Transform)(object)box, "View", new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(inset, 0f - inset), box.sizeDelta - new Vector2(inset * 2f + ((num2 > 0f) ? (num2 + 4f) : 0f), inset * 2f)); ((Component)val3).gameObject.AddComponent<RectMask2D>(); Image val4 = ((Component)val3).gameObject.AddComponent<Image>(); ((Graphic)val4).color = Color.clear; RectTransform val5 = Rect((Transform)(object)val3, "Content", new Vector2(0f, 1f), new Vector2(0f, 1f), Vector2.zero, new Vector2(val3.sizeDelta.x, 0f)); ScrollRect val6 = ((Component)val3).gameObject.AddComponent<ScrollRect>(); val6.content = val5; val6.viewport = val3; val6.horizontal = false; val6.movementType = (MovementType)2; val6.scrollSensitivity = (((Object)(object)val != (Object)null && val.scrollSensitivity > 0f) ? val.scrollSensitivity : 300f); val6.inertia = false; if ((Object)(object)val2 != (Object)null) { GameObject val7 = Object.Instantiate<GameObject>(((Component)val2).gameObject, (Transform)(object)box, false); ((Object)val7).name = "Scrollbar"; val7.SetActive(true); UIGamePad[] componentsInChildren = val7.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val8 in componentsInChildren) { Object.Destroy((Object)(object)val8); } RectTransform val9 = (RectTransform)val7.transform; val9.anchorMin = new Vector2(1f, 0f); val9.anchorMax = new Vector2(1f, 1f); val9.pivot = new Vector2(1f, 0.5f); val9.sizeDelta = new Vector2(num2, (0f - inset) * 2f); val9.anchoredPosition = new Vector2((0f - inset) * 0.5f, 0f); Scrollbar component = val7.GetComponent<Scrollbar>(); component.onValueChanged = new ScrollEvent(); val6.verticalScrollbar = component; val6.verticalScrollbarVisibility = (ScrollbarVisibility)1; } return val5; } internal static TMP_InputField InputField(Transform parent, Vector2 pos, Vector2 size, string text, string placeholder, int limit, Action<string> changed, Action<string> submit = null, float fontSize = 18f) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) TMP_InputField val = (((Object)(object)TextInput.instance != (Object)null) ? ((Component)TextInput.instance).GetComponentInChildren<TMP_InputField>(true) : null); if ((Object)(object)val == (Object)null && (Object)(object)Minimap.instance != (Object)null) { val = ((Component)Minimap.instance).GetComponentsInChildren<TMP_InputField>(true).FirstOrDefault(); } if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"PortalHubCanvas: the game's text box was not found (a game update moved it?): building one"); } GameObject val2 = new GameObject("PortalHubCanvasHolder"); val2.SetActive(false); TMP_InputField val3; if ((Object)(object)val != (Object)null) { GameObject copy = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform, false); val3 = copy.GetComponent<TMP_InputField>(); Type type = ((object)val3).GetType(); while (type != null && type != typeof(MonoBehaviour)) { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (typeof(UnityEventBase).IsAssignableFrom(fieldInfo.FieldType) && !fieldInfo.FieldType.IsAbstract) { try { fieldInfo.SetValue(val3, Activator.CreateInstance(fieldInfo.FieldType)); } catch (Exception) { } } } type = type.BaseType; } UIGamePad[] componentsInChildren = copy.GetComponentsInChildren<UIGamePad>(true); foreach (UIGamePad val4 in componentsInChildren) { Object.DestroyImmediate((Object)(object)val4); } foreach (Transform item in (from c in copy.GetComponentsInChildren<Transform>(true) where (Object)(object)c != (Object)(object)copy.transform && ((Object)c).name.StartsWith("gamepad_hint") select c).ToList()) { if ((Object)(object)item != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)item).gameObject); } } Localize[] componentsInChildren2 = copy.GetComponentsInChildren<Localize>(true); foreach (Localize val5 in componentsInChildren2) { Object.DestroyImmediate((Object)(object)val5); } TMP_SelectionCaret[] componentsInChildren3 = copy.GetComponentsInChildren<TMP_SelectionCaret>(true); foreach (TMP_SelectionCaret val6 in componentsInChildren3) { Object.DestroyImmediate((Object)(object)((Component)val6).gameObject); } } else { val3 = BuildInputField(val2.transform); } GameObject gameObject = ((Component)val3).gameObject; ((Object)gameObject).name = "InputField"; gameObject.SetActive(true); RectTransform val7 = (RectTransform)gameObject.transform; ((Transform)val7).SetParent(parent, false); Object.Destroy((Object)(object)val2); Vector2 val8 = default(Vector2); ((Vector2)(ref val8))..ctor(0f, 1f); val7.anchorMax = val8; val7.anchorMin = val8; val7.pivot = new Vector2(0f, 1f); val7.anchoredPosition = pos; val7.sizeDelta = size; ((Transform)val7).localScale = Vector3.one; ((Transform)val7).localRotation = Quaternion.identity; val3.contentType = (ContentType)0; val3.lineType = (LineType)0; val3.characterLimit = limit; ((Selectable)val3).interactable = true; val3.richText = false; TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[2] { val3.textComponent, (TMP_Text)/*isinst with value type is only supported in some contexts*/ }; foreach (TMP_Text val9 in array) { if (!((Object)(object)val9 == (Object)null)) { if ((Object)(object)val9.font == (Object)null) { val9.font = Sans; } val9.fontSize = fontSize; val9.enableAutoSizing = false; val9.enableWordWrapping = false; val9.alignment = (TextAlignmentOptions)4097; } } Graphic placeholder2 = val3.placeholder; TMP_Text val10 = (TMP_Text)(object)((placeholder2 is TMP_Text) ? placeholder2 : null); if (val10 != null) { val10.text = placeholder ?? ""; } else if ((Object)(object)val3.placeholder != (Object)null) { ((Component)val3.placeholder).gameObject.SetActive(false); } val3.text = text ?? ""; if (changed != null) { ((UnityEvent<string>)(object)val3.onValueChanged).AddListener((UnityAction<string>)delegate(string s) { changed(s ?? ""); }); } if (submit != null) { ((UnityEvent<string>)(object)val3.onSubmit).AddListener((UnityAction<string>)delegate(string s) { submit(s ?? ""); }); } return val3; } private static TMP_InputField BuildInputField(Transform holder) { //IL_0010: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_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_00b9: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Rect(holder, "InputField", new Vector2(0f, 1f), new Vector2(0f, 1f), Vector2.zero, new Vector2(200f, 36f)); Image val2 = ((Component)val).gameObject.AddComponent<Image>(); if ((Object)(object)_sunken != (Object)null) { Copy(_sunken, val2); } else { ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.45f); } RectTransform area = Rect((Transform)(object)val, "Text Area", Vector2.zero, new Vector2(0.5f, 0.5f), Vector2.zero, Vector2.zero); area.anchorMax = Vector2.one; area.offsetMin = new Vector2(10f, 2f); area.offsetMax = new Vector2(-10f, -2f); ((Component)area).gameObject.AddComponent<RectMask2D>(); TMP_Text val3 = Part("Placeholder", Dim); val3.fontStyle = (FontStyles)2; TMP_Text textComponent = Part("Text", Text); TMP_InputField val4 = ((Component)val).gameObject.AddComponent<TMP_InputField>(); val4.textViewport = area; val4.textComponent = textComponent; val4.placeholder = (Graphic)(object)val3; ((Selectable)val4).targetGraphic = (Graphic)(object)val2; val4.fontAsset = Sans; val4.customCaretColor = true; val4.caretColor = Text; val4.selectionColor = new Color(1f, 0.78f, 0.3f, 0.35f); return val4; TMP_Text Part(string name, Color color) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references) TMP_Text val5 = Label((Transform)(object)area, "", Vector2.zero, Vector2.zero, 18f, color, Sans, (TextAlignmentOptions)4097, Vector2.zero); ((Object)val5).name = name; RectTransform val6 = (RectTransform)val5.transform; val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; Vector2 offsetMin = (val6.offsetMax = Vector2.zero); val6.offsetMin = offsetMin; return val5; } } internal static string Plain(string text) { return "<noparse>" + (text ?? "").Replace("</noparse>", "") + "</noparse>"; } } [HarmonyPatch(typeof(PlayerController), "TakeInput")] internal static class GameUi_PlayerControllerTakeInput { private static void Postfix(ref bool __result) { if (GameUi.IsOpen()) { __result = false; } } } [HarmonyPatch(typeof(Player), "TakeInput")] internal static class GameUi_PlayerTakeInput { private static void Postfix(ref bool __result) { if (GameUi.IsOpen()) { __result = false; } } } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] internal static class GameUi_UpdateMouseCapture { private static bool Prefix() { if (!GameUi.IsOpen()) { return true; } ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); return false; } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class GameUi_ScrollWheel { private static void Postfix(ref float __result) { if (GameUi.IsOpen()) { __result = 0f; } } } [HarmonyPatch(typeof(Menu), "Update")] internal static class GameUi_EscapeCloses { internal static Action Close = delegate { }; private static bool Prefix() { if (!GameUi.IsOpen()) { return true; } if (!ZInput.GetKeyDown((KeyCode)27, true) && !ZInput.GetButtonDown("JoyMenu")) { return true; } Close(); return false; } } [HarmonyPatch(typeof(Minimap), "InTextInput")] internal static class GameUi_InTextInput { private static void Postfix(ref bool __result) { if (GameUi.IsOpen()) { __result = true; } } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class GameUi_InventoryKey { private static void Prefix() { if (GameUi.IsOpen() && (ZInput.GetButtonDown("Inventory") || ZInput.GetButtonDown("JoyButtonY"))) { bool typing = GameUi.Typing; ZInput.ResetButtonStatus("Inventory"); ZInput.ResetButtonStatus("JoyButtonY"); if (!typing) { GameUi_EscapeCloses.Close(); } } } } [HarmonyPatch(typeof(TeleportWorld), "Interact")] internal static class TeleportWorld_Interact { private static bool Prefix(TeleportWorld __instance, Humanoid human, bool hold, bool alt, ref bool __result) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.Enabled || hold || alt || (Object)(object)human != (Object)(object)Player.m_localPlayer) { return true; } if (!PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { ((Character)human).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null, false); __result = true; return false; } if (Time.unscaledTime < Plugin.ClosedAt + 0.25f) { __result = false; return false; } if (!instance.OpenWindow(__instance)) { return true; } __result = true; return false; } } [HarmonyPatch(typeof(TeleportWorld), "GetHoverText")] internal static class TeleportWorld_GetHoverText { private static void Postfix(TeleportWorld __instance, ref string __result) { Plugin instance = Plugin.Instance; if ((Object)(object)instance == (Object)null || !instance.Enabled || !instance.ShowHoverLine || string.IsNullOrEmpty(__result)) { return; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); ZDO val = (((Object)(object)component != (Object)null) ? component.GetZDO() : null); if (val != null) { string text = val.GetString("dh_dest", ""); if (text.Length != 0) { PortalInfo portalInfo = instance.Find(text); string text2 = ((portalInfo == null) ? Translations.T("portalhub_hover_another") : (string.IsNullOrWhiteSpace(portalInfo.Name) ? Translations.T("portalhub_hover_unnamed") : portalInfo.Name)); __result = __result + "\n<color=#F2C75A>" + Translations.T("portalhub_hover_goes_to") + "</color> " + text2; } } } } [HarmonyPatch(typeof(Game), "ConnectPortals")] internal static class Game_ConnectPortals { internal static bool Filtering; private static void Prefix() { Filtering = false; Plugin.ApplyDestinations(); Filtering = (Object)(object)Plugin.Instance != (Object)null && Plugin.Instance.Enabled; } private static void Postfix() { Filtering = false; } private static void Finalizer() { Filtering = false; } } [HarmonyPatch(typeof(ZDOMan), "GetPortalList")] internal static class ZDOMan_GetPortalList { private static void Postfix(List<ZDO> __result) { if (Game_ConnectPortals.Filtering) { __result.RemoveAll(Plugin.HasDest); } } } [BepInPlugin("com.quad.portalhub", "PortalHub", "1.4.3")] public class Plugin : BaseUnityPlugin { private class LinkPart { public RectTransform Rect; public Image Image; public Vector2 A; public Vector2 B; public Color Color; } private class PendingWrite { public readonly Dictionary<string, string> Values = new Dictionary<string, string>(); public float At; } private class Row { public PortalInfo Info; public float Distance; public bool Favorite; public string Where; } public const string Guid = "com.quad.portalhub"; public const string OldGuid = "com.dhack.portalhub"; public const string Name = "PortalHub"; public const string Version = "1.4.3"; internal static Plugin Instance; internal static ServerSettings Synced; private ConfigEntry<bool> _enabled; private ConfigEntry<bool> _showHoverLine; private ConfigEntry<bool> _linkBothWays; private ConfigEntry<bool> _hideWarded; private ConfigEntry<string> _favorites; private Harmony _harmony; private int _awakeFrame; private bool? _xportal; private ConfigEntry<bool> _mapIcons; private ConfigEntry<bool> _mapLines; private readonly Dictionary<string, PinData> _pins = new Dictionary<string, PinData>(); private float _pinsFor = -1f; private float _nextPinCheck; private static readonly FieldRef<Minimap, List<PinData>> PinList = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins"); private const string LinkLayerName = "PortalHubLinks"; private const float LinkWidth = 2.5f; private RectTransform _linkLayer; private readonly List<LinkPart> _linkParts = new List<LinkPart>(); private Dictionary<string, PortalInfo> _byId = new Dictionary<string, PortalInfo>(); private float _byIdFor = -1f; private const string RpcRequest = "DH_PortalsRequest"; private const string RpcList = "DH_PortalsList"; private const string RpcSet = "DH_PortalsSet"; private const string RpcMsg = "DH_PortalsMsg"; private const string DestKey = "dh_dest"; private const string PidKey = "dh_pid"; private const string DestByKey = "dh_destby"; private const string RpcWrite = "DH_PortalsWrite"; private const float WriteTimeout = 4f; private static readonly Dictionary<ZDOID, PendingWrite> _pendingWrites = new Dictionary<ZDOID, PendingWrite>(); internal List<PortalInfo> Portals = new List<PortalInfo>(); internal float PortalsAt = -999f; private float _nextAsk; private float _nextNearCheck; private ZRoutedRpc _registeredOn; private static readonly MethodInfo SetConnectionMethod = AccessTools.Method(typeof(Game), "SetConnection", (Type[])null, (Type[])null); private static Dictionary<int, float> _wardRadius; private static readonly List<ZDO> _near = new List<ZDO>(); private const float WinW = 760f; private const float WinH = 740f; private const float Pad = 30f; private const float ListTop = 306f; private const float RowH = 44f; internal static float ClosedAt = -1f; private RectTransform _window; private RectTransform _chrome; private RectTransform _list; private TMP_InputField _nameField; private TMP_InputField _searchField; private bool _open; private bool _scrollTop; private string _chromeShown = ""; private string _listKey; private string _listShown = ""; private readonly Dictionary<int, GameObject> _rowObjects = new Dictionary<int, GameObject>(); private Action _pending; private TeleportWorld _portal; private string _portalId = ""; private string _search = ""; private string _nameEdit = ""; private bool _sortByName; private float _openedAt; private float _openedAtUnscaled; private string _expectDest; private float _expectBy; private List<Row> _rows = new List<Row>(); private string _rowsKey; private int _first = -1; private int _last = -1; internal bool Enabled { get { if (_enabled.Value) { return !XPortalInstalled; } return false; } } internal bool HideWarded => _hideWarded.Value; internal bool XPortalInstalled { get { if (_xportal.HasValue) { return _xportal.Value; } if ((Object)(object)ZNet.instance == (Object)null) { return false; } _xportal = Chainloader.PluginInfos.ContainsKey("yay.spikehimself.xportal"); if (_xportal.Value) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"XPortal is installed: PortalHub stands down and leaves portals to it (both link portals, in ways that undo each other)."); } return _xportal.Value; } } internal bool ShowHoverLine => _showHoverLine.Value; private static bool IsServer { get { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } } internal static bool WindowOpen { get { if ((Object)(object)Instance != (Object)null) { return (Object)(object)Instance._window != (Object)null; } return false; } } private PortalInfo ThisPortal { get { RefreshPortalId(); return Find(_portalId); } } private void Awake() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown Migration.FromOldGuid((BaseUnityPlugin)(object)this, "com.dhack.portalhub"); Translations.Load((BaseUnityPlugin)(object)this); Instance = this; Synced = new ServerSettings("com.quad.portalhub", ((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); _enabled = Synced.Add<bool>(((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Use the portal menu when you press E on a portal. (Off: portals work like in the base game.) In multiplayer the server's value applies.")); _hideWarded = Synced.Add<bool>(((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideWardedPortals", false, "Leave portals inside someone else's protected area (a switched-on ward you are not on) out of each player's list and map. (Either way, nobody can change a portal in such an area or link a portal into one.) In multiplayer the server's value applies.")); _showHoverLine = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowDestinationOnHover", true, "When you look at a portal, show where it goes."); _linkBothWays = ((BaseUnityPlugin)this).Config.Bind<bool>("Menu", "LinkBothWays", true, "Picking a destination also links that portal back to this one."); _favorites = ((BaseUnityPlugin)this).Config.Bind<string>("Menu", "Favorites", "", "Portals you starred (managed by the menu; you do not need to edit this)."); BindMapConfig(); _awakeFrame = Time.frameCount; _harmony = new Harmony("com.quad.portalhub"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PortalHub 1.4.3 loaded"); if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Chat.instance != (Object)null) { ((Terminal)Chat.instance).AddString("[Mod]", "PortalHub v1.4.3 reloaded", (Type)1, false); } } private void OnDestroy() { CloseWindow(); GameUi.Destroy(); DestroyMapLines(); ClearPins(Minimap.instance); UnregisterRpc(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Synced?.Dispose(); Translations.Unload(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { Synced?.Update(); UpdateNetwork(); UpdateWindow(); UpdateMap(); } private void LateUpdate() { UpdateMapLines(); } private void Tell(string message) { if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false); } } private HashSet<string> Favorites() { return new HashSet<string>(_favorites.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } private void ToggleFavorite(string id) { HashSet<string> hashSet = Favorites(); if (!hashSet.Remove(id)) { hashSet.Add(id); } _favorites.Value = string.Join(",", hashSet.ToArray()); _rowsKey = null; } private void BindMapConfig() { _mapIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowPortals", true, "Show every portal on the map with its name."); _mapLines = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ShowLinks", true, "On the big map, draw a line from each portal to where it goes (an arrow if it only goes one way)."); } private void UpdateMap() { Minimap instance = Minimap.instance; if ((Object)(object)instance == (Object)null) { return; } if (!Enabled || !_mapIcons.Value || (Object)(object)Player.m_localPlayer == (Object)null) { ClearPins(instance); return; } if (Minimap.IsOpen() && Time.time >= _nextAsk) { _nextAsk = Time.time + 10f; RequestList(); } if (Time.time >= _nextPinCheck) { _nextPinCheck = Time.time + 1f; List<PinData> all = PinList.Invoke(instance); if (_pins.Values.Any((PinData p) => !all.Contains(p))) { _pinsFor = -1f; } } if (_pinsFor != PortalsAt) { SyncPins(instance); _pinsFor = PortalsAt; } } private void SyncPins(Minimap map) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) ClearPins(map); foreach (PortalInfo portal in Portals) { _pins[portal.Id] = map.AddPin(portal.Pos, (PinType)3, string.IsNullOrWhiteSpace(portal.Name) ? Localization.instance.Localize("$piece_portal") : portal.Name, false, false, 0L, default(PlatformUserID)); } } private void ClearPins(Minimap map) { if (_pins.Count == 0) { return; } if ((Object)(object)map != (Object)null) { foreach (PinData value in _pins.Values) { map.RemovePin(value); } } _pins.Clear(); _pinsFor = -1f; } private void UpdateMapLines() { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) Minimap instance = Minimap.instance; RectTransform val = (((Object)(object)instance != (Object)null) ? instance.m_pinRootLarge : null); if ((Object)(object)val == (Object)null || !_mapLines.Value || !Enabled || !Minimap.IsOpen() || _pins.Count == 0) { if ((Object)(object)_linkLayer != (Object)null && ((Component)_linkLayer).gameObject.activeSelf) { ((Component)_linkLayer).gameObject.SetActive(false); } return; } Vector2 val3; if ((Object)(object)_linkLayer == (Object)null || (Object)(object)((Transform)_linkLayer).parent != (Object)(object)val) { DestroyMapLines(); foreach (Transform item in (from Transform t in (IEnumerable)val where ((Object)t).name == "PortalHubLinks" select t).ToList()) { Object.Destroy((Object)(object)((Component)item).gameObject); } GameObject val2 = new GameObject("PortalHubLinks", new Type[1] { typeof(RectTransform) }); _linkLayer = (RectTransform)val2.transform; ((Transform)_linkLayer).SetParent((Transform)(object)val, false); _linkLayer.anchorMin = Vector2.zero; _linkLayer.anchorMax = Vector2.one; val3 = (_linkLayer.offsetMin = (_linkLayer.offsetMax = Vector2.zero)); } if (!((Component)_linkLayer).gameObject.activeSelf) { ((Component)_linkLayer).gameObject.SetActive(true); } if (((Transform)_linkLayer).GetSiblingIndex() != 0) { ((Transform)_linkLayer).SetAsFirstSibling(); } if (_byIdFor != PortalsAt) { _byIdFor = PortalsAt; _byId = new Dictionary<string, PortalInfo>(); foreach (PortalInfo portal in Portals) { _byId[portal.Id] = portal; } } int num = 0; HashSet<string> hashSet = new HashSet<string>(); Vector2 val5 = default(Vector2); foreach (PortalInfo portal2 in Portals) { if (portal2.Dest.Length == 0 || !_pins.TryGetValue(portal2.Id, out var value) || !_byId.TryGetValue(portal2.Dest, out var value2) || !_pins.TryGetValue(value2.Id, out var value3)) { continue; } bool flag = value2.Dest == portal2.Id; if (flag && !hashSet.Add(value2.Id + ">" + portal2.Id)) { continue; } if (flag) { hashSet.Add(portal2.Id + ">" + value2.Id); } if (!OnMap(value, val, out var position) || !OnMap(value3, val, out var position2)) { continue; } Color color = (flag ? new Color(0.95f, 0.78f, 0.35f, 0.85f) : new Color(0.55f, 0.85f, 1f, 0.85f)); Piece(num++, position, position2, color); if (!flag) { val3 = position2 - position; if (!(((Vector2)(ref val3)).magnitude < 60f)) { val3 = position2 - position; Vector2 normalized = ((Vector2)(ref val3)).normalized; ((Vector2)(ref val5))..ctor(0f - normalized.y, normalized.x); Vector2 val6 = position2 - normalized * 18f; Piece(num++, val6, val6 - normalized * 12f + val5 * 7f, color); Piece(num++, val6, val6 - normalized * 12f - val5 * 7f, color); } } } for (int num2 = num; num2 < _linkParts.Count; num2++) { if ((Object)(object)_linkParts[num2].Rect != (Object)null && ((Component)_linkParts[num2].Rect).gameObject.activeSelf) { ((Component)_linkParts[num2].Rect).gameObject.SetActive(false); } } } private bool OnMap(PinData pin, RectTransform root, out Vector2 position) { //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) position = Vector2.zero; RectTransform uiElement = pin.m_uiElement; if ((Object)(object)uiElement == (Object)null || (Object)(object)((Transform)uiElement).parent != (Object)(object)root || !((Component)uiElement).gameObject.activeInHierarchy) { return false; } position = Vector2.op_Implicit(((Transform)_linkLayer).InverseTransformPoint(((Transform)uiElement).position)); return true; } private void Piece(int index, Vector2 a, Vector2 b, Color color) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) while (_linkParts.Count <= index) { _linkParts.Add(new LinkPart()); } LinkPart linkPart = _linkParts[index]; Vector2 val2 = default(Vector2); if ((Object)(object)linkPart.Rect == (Object)null) { GameObject val = new GameObject("Link", new Type[1] { typeof(RectTransform) }); linkPart.Rect = (RectTransform)val.transform; ((Transform)linkPart.Rect).SetParent((Transform)(object)_linkLayer, false); RectTransform rect = linkPart.Rect; RectTransform rect2 = linkPart.Rect; ((Vector2)(ref val2))..ctor(0.5f, 0.5f); rect2.anchorMax = val2; rect.anchorMin = val2; linkPart.Rect.pivot = new Vector2(0f, 0.5f); linkPart.Image = val.AddComponent<Image>(); ((Graphic)linkPart.Image).raycastTarget = false; val2 = (linkPart.A = (linkPart.B = new Vector2(float.NaN, float.NaN))); linkPart.Color = Color.clear; } if (!((Component)linkPart.Rect).gameObject.activeSelf) { ((Component)linkPart.Rect).gameObject.SetActive(true); } if (linkPart.Color != color) { linkPart.Color = color; ((Graphic)linkPart.Image).color = color; } val2 = linkPart.A - a; if (((Vector2)(ref val2)).sqrMagnitude < 0.01f) { val2 = linkPart.B - b; if (((Vector2)(ref val2)).sqrMagnitude < 0.01f) { return; } } linkPart.A = a; linkPart.B = b; Vector2 val3 = b - a; ((Transform)linkPart.Rect).localPosition = Vector2.op_Implicit(a); linkPart.Rect.sizeDelta = new Vector2(((Vector2)(ref val3)).magnitude, 2.5f); ((Transform)linkPart.Rect).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val3.y, val3.x) * 57.29578f); } private void DestroyMapLines() { if ((Object)(object)_linkLayer != (Object)null) { Object.Destroy((Object)(object)((Component)_linkLayer).gameObject); } _linkLayer = null; _linkParts.Clear(); } internal static string PortalId(ZDO zdo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) string text = Stored(zdo, "dh_pid"); if (text.Length <= 0) { return Key(zdo.m_uid); } return text; } private static string EnsurePid(ZDO zdo) { string text = Stored(zdo, "dh_pid"); if (text.Length > 0) { return text; } text = System.Guid.NewGuid().ToString("N").Substring(0, 12); Write(zdo, "dh_pid", text); return text; } private static ZDO ResolvePortal(string id, Dictionary<string, ZDO> byPid = null) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(id) || ZDOMan.instance == null) { return null; } if (id.IndexOf(':') >= 0) { ZDOID id2; ZDO val = (TryParse(id, out id2) ? ZDOMan.instance.GetZDO(id2) : null); if (val == null || !IsPortalZdo(val)) { return null; } return val; } if (byPid != null) { if (!byPid.TryGetValue(id, out var value)) { return null; } return value; } foreach (ZDO portal in ZDOMan.instance.GetPortalList()) { if (Stored(portal, "dh_pid") == id) { return portal; } } return null; } private static string Stored(ZDO zdo, string key) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (_pendingWrites.Count > 0 && _pendingWrites.TryGetValue(zdo.m_uid, out var value) && value.Values.TryGetValue(key, out var value2)) { return value2; } return zdo.GetString(key, ""); } private static void Write(ZDO zdo, params string[] keyValues) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) long sessionID = ZDOMan.GetSessionID(); long owner = zdo.GetOwner(); if (owner == sessionID || owner == 0L || (Object)(object)ZNet.instance == (Object)null || ZNet.instance.GetPeer(owner) == null) { WriteHere(zdo, keyValues); return; } if (!_pendingWrites.TryGetValue(zdo.m_uid, out var value)) { value = (_pendingWrites[zdo.m_uid] = new PendingWrite()); } for (int i = 0; i + 1 < keyValues.Length; i += 2) { value.Values[keyValues[i]] = keyValues[i + 1]; } value.At = Time.time; ZRoutedRpc.instance.InvokeRoutedRPC(owner, "DH_PortalsWrite", new object[2] { zdo.m_uid, string.Join("|", keyValues) }); } private static void WriteHere(ZDO zdo, string[] keyValues) { //IL_0011: 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_0064: Unknown result type (might be due to invalid IL or missing references) zdo.SetOwner(ZDOMan.GetSessionID()); _pendingWrites.TryGetValue(zdo.m_uid, out var value); for (int i = 0; i + 1 < keyValues.Length; i += 2) { zdo.Set(keyValues[i], keyValues[i + 1]); value?.Values.Remove(keyValues[i]); } if (value != null && value.Values.Count == 0) { _pendingWrites.Remove(zdo.m_uid); } ZDOMan.instance.ForceSendZDO(zdo.m_uid); } private static void SettlePending() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_004f: 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_014f: Unknown result type (might be due to invalid IL or missing references) if (_pendingWrites.Count == 0) { return; } foreach (ZDOID item in _pendingWrites.Keys.ToList()) { PendingWrite pendingWrite = _pendingWrites[item]; ZDO zDO = ZDOMan.instance.GetZDO(item); if (zDO == null) { _pendingWrites.Remove(item); continue; } foreach (string item2 in pendingWrite.Values.Keys.ToList()) { if (zDO.GetString(item2, "") == pendingWrite.Values[item2]) { pendingWrite.Values.Remove(item2); } } if (pendingWrite.Values.Count == 0) { _pendingWrites.Remove(item); } else { if (Time.time - pendingWrite.At < 4f) { continue; } List<string> list = new List<string>(); foreach (KeyValuePair<string, string> value in pendingWrite.Values) { list.Add(value.Key); list.Add(value.Value); } _pendingWrites.Remove(item); WriteHere(zDO, list.ToArray()); } } } private void OnWrite(long sender, ZDOID id, string payload) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetServerPeer() : null); if (val == null || sender != val.m_uid) { return; } ZDO val2 = ((ZDOMan.instance != null) ? ZDOMan.instance.GetZDO(id) : null); if (val2 == null || !val2.IsOwner()) { return; } string[] array = (payload ?? "").Split(new char[1] { '|' }); for (int i = 0; i + 1 < array.Length; i += 2) { if (array[i] == "dh_pid" || array[i] == "dh_dest" || array[i] == "dh_destby") { val2.Set(array[i], array[i + 1]); } } ZDOMan.instance.ForceSendZDO(id); } internal static string Key(ZDOID id) { return ((ZDOID)(ref id)).UserID.ToString(CultureInfo.InvariantCulture) + ":" + ((ZDOID)(ref id)).ID.ToString(CultureInfo.InvariantCulture); } internal static bool TryParse(string key, out ZDOID id) { //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_0053: 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) id = ZDOID.None; string[] array = (key ?? "").Split(new char[1] { ':' }); if (array.Length == 2 && long.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && uint.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { id = new ZDOID(result, result2); return true; } return false; } private void UpdateNetwork() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance == null) { _registeredOn = null; } else if (Time.frameCount > _awakeFrame + 2) { if (instance != _registeredOn) { _registeredOn = instance; Portals = new List<PortalInfo>(); PortalsAt = -999f; _rowsKey = null; _pendingWrites.Clear(); UnregisterRpc(); instance.Register<string>("DH_PortalsRequest", (Action<long, string>)OnRequest); instance.Register<string>("DH_PortalsList", (Action<long, string>)OnList); instance.Register<string>("DH_PortalsSet", (Action<long, string>)OnSet); instance.Register<string>("DH_PortalsMsg", (Action<long, string>)OnMsg); instance.Register<ZDOID, string>("DH_PortalsWrite", (Action<long, ZDOID, string>)OnWrite); } if (Time.time >= _nextAsk && (Object)(object)Player.m_localPlayer != (Object)null && (WindowOpen || NearAPortalThrottled())) { _nextAsk = Time.time + (WindowOpen ? 5f : 20f); RequestList(); } } } private bool NearAPortalThrottled() { if (Time.time < _nextNearCheck) { return false; } _nextNearCheck = Time.time + 1f; return NearAPortal(); } private static bool NearAPortal() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; TeleportWorld[] array = Object.FindObjectsOfType<TeleportWorld>(); foreach (TeleportWorld val in array) { if ((Object)(object)val != (Object)null) { Vector3 val2 = ((Component)val).transform.position - ((Component)localPlayer).transform.position; if (((Vector3)(ref val2)).sqrMagnitude < 144f) { return true; } } } return false; } private static void UnregisterRpc() { if (ZRoutedRpc.instance != null && AccessTools.Field(typeof(ZRoutedRpc), "m_functions").GetValue(ZRoutedRpc.instance) is IDictionary dictionary) { string[] array = new string[5] { "DH_PortalsRequest", "DH_PortalsList", "DH_PortalsSet", "DH_PortalsMsg", "DH_PortalsWrite" }; foreach (string text in array) { dictionary.Remove(StringExtensionMethods.GetStableHashCode(text)); } } } internal void RequestList() { if (ZRoutedRpc.instance != null) { if (IsServer) { SetList(BuildList(CharacterOf(ZDOMan.GetSessionID()))); return; } ZRoutedRpc.instance.InvokeRoutedRPC("DH_PortalsRequest", new object[1] { "" }); } } private static string BuildList(long character) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); bool flag = (Object)(object)Instance != (Object)null && Instance.HideWarded; foreach (ZDO portal in ZDOMan.instance.GetPortalList()) { Vector3 position = portal.GetPosition(); if (!flag || MayUse(position, character)) { string text = (portal.GetString(ZDOVars.s_tag, "") ?? "").Replace('|', ' ').Replace('\n', ' '); list.Add(string.Join("|", EnsurePid(portal), text, position.x.ToString("0.#", CultureInfo.InvariantCulture), position.y.ToString("0.#", CultureInfo.InvariantCulture), position.z.ToString("0.#", CultureInfo.InvariantCulture), Stored(portal, "dh_dest"))); } } return string.Join("\n", list.ToArray()); } private void SetList(string payload) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) List<PortalInfo> list = new List<PortalInfo>(); string[] array = (payload ?? "").Split(new char[1] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { string[] array2 = text.Split(new char[1] { '|' }); if (array2.Length >= 6) { list.Add(new PortalInfo { Id = array2[0], Name = array2[1], Dest = array2[5], Pos = new Vector3(Num(array2[2]), Num(array2[3]), Num(array2[4])) }); } } Portals = list; PortalsAt = Time.time; _rowsKey = null; } private static float Num(string s) { if (!float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return 0f; } return result; } private void OnRequest(long sender, string _) { if (IsServer) { ZRoutedRpc.instance.InvokeRoutedRPC(sender, "DH_PortalsList", new object[1] { BuildList(CharacterOf(sender)) }); } } private void OnList(long sender, string payload) { SetList(payload); } internal PortalInfo Find(string id) { return Portals.FirstOrDefault((PortalInfo p) => p.Id == id); } internal void SetDestination(string portal, string dest, bool both) { string text = portal + "|" + dest + "|" + (both ? "1" : "0"); if (IsServer) { ApplySet(ZDOMan.GetSessionID(), text); } else { ZRoutedRpc.instance.InvokeRoutedRPC("DH_PortalsSet", new object[1] { text }); } _nextAsk = Time.time + 0.8f; } private void OnSet(long sender, string payload) { if (IsServer) { ApplySet(sender, payload); } } private void OnMsg(long sender, string text) { Tell(text); } private static void TellPlayer(long to, string text) { if (to == ZDOMan.GetSessionID()) { Instance?.Tell(text); return; } ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(to, "DH_PortalsMsg", new object[1] { text }); } } private static void ApplySet(long sender, string payload) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) string[] array = payload.Split(new char[1] { '|' }); if (array.Length < 3) { return; } ZDO val = ResolvePortal(array[0]); if (val == null) { return; } long num = CharacterOf(sender); if (!MayUse(val.GetPosition(), num)) { TellPlayer(sender, "$portalhub_msg_warded"); return; } bool flag = string.IsNullOrEmpty(array[1]); ZDO val2 = null; if (!flag) { val2 = ResolvePortal(array[1]); if (val2 == null || val2 == val) { return; } if (!MayUse(val2.GetPosition(), num)) { TellPlayer(sender, "$portalhub_msg_warded"); return; } } SetDest(val, flag ? "" : EnsurePid(val2), num); if (!flag && array[2] == "1") { SetDest(val2, EnsurePid(val), num); } if (flag) { Connect(val, ZDOID.None); } ApplyDestinations(); } private static bool IsPortalZdo(ZDO zdo) { if ((Object)(object)Game.instance != (Object)null) { return Game.instance.PortalPrefabHash.Contains(zdo.GetPrefab()); } return false; } private static void SetDest(ZDO zdo, string dest, long by) { Write(zdo, "dh_dest", dest, "dh_destby", (dest.Length > 0) ? by.ToString(CultureInfo.InvariantCulture) : ""); } private static long LinkedBy(ZDO portal) { string text = Stored(portal, "dh_destby"); if (text.Length <= 0 || !long.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return 0L; } return result; } private static void Connect(ZDO portal, ZDOID target) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Game.instance == (Object)null) && !(SetConnectionMethod == null)) { SetConnectionMethod.Invoke(Game.instance, new object[3] { portal, target, false }); } } internal static void ApplyDestinations() { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0121: Unknown result type (might be due to invalid IL or missing references) if (!IsServer || (Object)(object)Instance == (Object)null || !Instance.Enabled || ZDOMan.instance == null) { return; } SettlePending(); List<ZDO> portalList = ZDOMan.instance.GetPortalList(); Dictionary<string, ZDO> dictionary = new Dictionary<string, ZDO>(portalList.Count); foreach (ZDO item in portalList) { dictionary[EnsurePid(item)] = item; } foreach (ZDO item2 in portalList) { string text = Stored(item2, "dh_dest"); if (text.Length != 0) { ZDO val = ((text.IndexOf(':') >= 0) ? null : ResolvePortal(text, dictionary)); long num = LinkedBy(item2); if (val == null || val == item2 || (num != 0L && !MayUse(val.GetPosition(), num))) { SetDest(item2, "", 0L); Connect(item2, ZDOID.None); } else if (item2.GetConnectionZDOID((ConnectionType)1) != val.m_uid) { Connect(item2, val.m_uid); } } } } internal static bool HasDest(ZDO zdo) { return Stored(zdo, "dh_dest").Length > 0; } private static long CharacterOf(long sender) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (sender == ZDOMan.GetSessionID()) { if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return 0L; } return Player.m_localPlayer.GetPlayerID(); } ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(sender) : null); if (val == null) { return 0L; } ZDO val2 = ((!((ZDOID)(ref val.m_characterID)).IsNone()) ? ZDOMan.instance.GetZDO(val.m_characterID) : null); long num = ((val2 != null) ? val2.GetLong(ZDOVars.s_playerID, 0L) : 0); if (num == 0L) { return val.m_playerID; } return num; } private static bool MayUse(Vector3 point, long character) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNetScene.instance == (Object)null || ZDOMan.instance == null) { return true; } if (_wardRadius == null) { _wardRadius = new Dictionary<int, float>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { PrivateArea val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<PrivateArea>() : null); if ((Object)(object)val != (Object)null) { _wardRadius[StringExtensionMethods.GetStableHashCode(((Object)prefab).name)] = val.m_radius; } } } _near.Clear(); ZDOMan.instance.FindSectorObjects(ZoneSystem.GetZone(point), new SimulationDistance(1, 0, false), _near, (List<ZDO>)null); bool flag = false; foreach (ZDO item in _near) { if (_wardRadius.TryGetValue(item.GetPrefab(), out var value) && item.GetBool(ZDOVars.s_enabled, false) && !(Utils.DistanceXZ(item.GetPosition(), point) >= value)) { if (character != 0L && (item.GetLong(ZDOVars.s_creator, 0L) == character || Permitted(item, character))) { return true; } flag = true; } } return !flag; } private static bool Permitted(ZDO ward, long character) { int num = ward.GetInt(ZDOVars.s_permitted, 0); for (int i = 0; i < num; i++) { if (ward.GetLong("pu_id" + i, 0L) == character) { return true; } } return false; } internal bool OpenWindow(TeleportWorld portal) { ZNetView component = ((Component)portal).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || component.GetZDO() == null) { return true; } if (!GameUi.Ready() || (Object)(object)GameUi.Canvas == (Object)null) { return false; } CloseWindow(); GameUi.IsOpen = () => WindowOpen; GameUi_EscapeCloses.Close = CloseFromEscape; _portal = portal; ZDO zDO = component.GetZDO(); _portalId = PortalId(zDO); _search = ""; _rowsKey = null; _pending = null; _expectDest = null; if (InventoryGui.IsVisible()) { InventoryGui.instance.Hide(); } _openedAt = Time.time; _openedAtUnscaled = Time.unscaledTime; _nameEdit = zDO.GetString(ZDOVars.s_tag, "") ?? ""; _open = true; BuildWindow(); RequestList(); _nextAsk = Time.time + 5f; return true; } public static void CloseFromEscape() { Instance?.CloseWindow(); } private void CloseWindow() { if ((Object)(object)_window != (Object)null) { Object.Destroy((Object)(object)((Component)_window).gameObject); } if (_open) { ClosedAt = Time.unscaledTime; UITooltip.HideTooltip(); } _window = (_chrome = (_list = null)); _nameField = (_searchField = null); _rowObjects.Clear(); _chromeShown = (_listShown = ""); _listKey = null; _open = false; _portal = null; _pending = null; } private void UpdateWindow() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!_open) { return; } if ((Object)(object)_window == (Object)null) { CloseWindow(); return; } Player localPlayer = Player.m_localPlayer; bool flag = !GameUi.Typing && Time.unscaledTime > _openedAtUnscaled + 0.2f && ZInput.GetButtonDown("Use"); if (!((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || (Object)(object)_portal == (Object)null || Menu.IsVisible() || flag)) { Vector3 val = ((Component)_portal).transform.position - ((Component)localPlayer).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > 400f)) { if (_pending != null) { Action pending = _pending; _pending = null; pending(); if (!_open) { return; } } if (_expectDest != null && Time.time > _expectBy) { PortalInfo thisPortal = ThisPortal; if (thisPortal == null || thisPortal.Dest != _expectDest) { Tell(Translations.T("portalhub_nothing_changed")); } _expectDest = null; } BuildRows(); if (ChromeSignature() != _chromeShown) { BuildChrome(); } UpdateList(); return; } } CloseWindow(); } private void RefreshPortalId() { ZNetView val = (((Object)(object)_portal != (Object)null) ? ((Component)_portal).GetComponent<ZNetView>() : null); ZDO val2 = (((Object)(object)val != (Object)null && val.IsValid()) ? val.GetZDO() : null); if (val2 != null) { string text = PortalId(val2); if (text != _portalId) { _portalId = text; _rowsKey = null; } } } private void BuildRows() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) string text = _search + "|" + _sortByName + "|" + PortalsAt + "|" + _favorites.Value; if (text == _rowsKey) { return; } _rowsKey = text; Vector3 from = (((Object)(object)_portal != (Object)null) ? ((Component)_portal).transform.position : Vector3.zero); HashSet<string> favorites = Favorites(); IEnumerable<Row> source = from p in Portals where p.Id != _portalId select new Row { Info = p, Distance = Vector3.Distance(@from, p.Pos), Favorite = favorites.Contains(p.Id), Where = BiomeOf(p.Pos) }; if (_search.Length > 0) { source = source.Where((Row r) => NameOf(r.Info).IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0 || r.Where.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0); } IOrderedEnumerable<Row> source2 = source.OrderByDescending((Row r) => r.Favorite); _rows = (_sortByName ? source2.ThenBy<Row, string>((Row r) => NameOf(r.Info), StringComparer.OrdinalIgnoreCase) : source2.ThenBy((Row r) => r.Distance)).ToList(); } private static string NameOf(PortalInfo p) { if (!string.IsNullOrWhiteSpace(p.Name)) { return p.Name; } return Translations.T("portalhub_no_name", (int)p.Pos.x, (int)p.Pos.z); } private static string BiomeOf(Vector3 pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) try { if (WorldGenerator.instance == null) { return ""; } string text = ((object)WorldGenerator.instance.GetBiome(pos)/*cast due to .constrained prefix*/).ToString(); return Localization.instance.Localize("$biome_" + text.ToLowerInvariant()); } catch (Exception) { return ""; } } private static string Far(float metres) { if (!(metres >= 1000f)) { return Translations.T("portalhub_metres", (int)metres); } return Translations.T("portalhub_km", (metres / 1000f).ToString("0.0")); } private void SaveName() { PortalInfo thisPortal = ThisPortal; if ((thisPortal == null || _nameEdit != thisPortal.Name) && (Object)(object)_portal != (Object)null) { _portal.SetText(_nameEdit.Trim()); _nextAsk = Time.time + 0.8f; } } private void Link(string dest) { SetDestination(_portalId, dest, _linkBothWays.Value); _expectDest = dest; _expectBy = Time.time + 4f; } private static void ShowOnMap(Vector3 pos) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance != (Object)null) { Minimap.instance.ShowPointOnMap(pos); } } private void BuildWindow() { //IL_0010: 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) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) _window = GameUi.Window("PortalHubWindow", new Vector2(760f, 740f)); Transform window = (Transform)(object)_window; _nameField = GameUi.InputField(window, new Vector2(110f, -92f), new Vector2(488f, 40f), _nameEdit, Translations.T("portalhub_name_placeholder"), 16, delegate(string s) { _nameEdit = s; }, delegate { _pending = SaveName; }, 19f); _searchField = GameUi.InputField(window, new Vector2(110f, -206f), new Vector2(344f, 40f), "", Translations.T("portalhub_search_placeholder"), 40, delegate(string s) { _search = s; _scrollTop = true; }, null, 19f); RectTransform box = GameUi.Box(window, new Vector2(24f, -306f), new Vector2(712f, 350f)); _list = GameUi.Scroll(box, 8f); ScrollRect component = ((Component)((Transform)_list).parent).GetComponent<ScrollRect>(); if ((Object)(object)component != (Object)null) { ((UnityEvent<Vector2>)(object)component.onValueChanged).AddListener((UnityAction<Vector2>)delegate { if (_open && (Object)(object)_list != (Object)null) { FillRows(ThisPortal); } }); } BuildChrome(); } private string ChromeSignature() { //IL_0099: 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) PortalInfo thisPortal = ThisPortal; PortalInfo portalInfo = ((thisPortal != null && thisPortal.Dest.Length > 0) ? Find(thisPortal.Dest) : null); bool flag = !IsServer && PortalsAt < _openedAt && Time.time - _openedAt > 3f; return string.Join("|", (thisPortal != null) ? thisPortal.Name : "\u0001", (thisPortal != null) ? thisPortal.Dest : "", (portalInfo != null) ? (NameOf(portalInfo) + Far(Vector3.Distance(thisPortal.Pos, portalInfo.Pos))) : "", (thisPortal == null || _nameEdit != thisPortal.Name).ToString(), flag.ToString(), (_search.Length > 0).ToString(), _sortByName.ToString(), _linkBothWays.Value.ToString(), (Portals.Count <= 1).ToString()); } private void BuildChrome() { //IL_0054: 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_0068: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or m