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 MapTeleport v1.1.0
plugins/MapTeleport.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("MapTeleport")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+eb5eeb05cdc1f0cb8f43ddb1ab882ab5a6a8bfa5")] [assembly: AssemblyProduct("MapTeleport")] [assembly: AssemblyTitle("MapTeleport")] [assembly: AssemblyVersion("1.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 Jatify.MapTeleport { internal static class JatifyLook { private const string Guid = "jatify.ui"; private static Type _look; private static Assembly _from; internal static bool On => Look() != null; private static Type Look() { if (!Chainloader.PluginInfos.TryGetValue("jatify.ui", out var value) || (Object)(object)value.Instance == (Object)null) { return null; } Assembly assembly = ((object)value.Instance).GetType().Assembly; if (assembly != _from) { _from = assembly; _look = assembly.GetType("Jatify.UI.Look"); } return _look; } private static object Call(string method, object arg) { Type type = Look(); if (type == null) { return null; } try { return type.GetMethod(method)?.Invoke(null, new object[1] { arg }); } catch { return null; } } internal static Color Color(string token, Color fallback) { //IL_0028: 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) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!(Call("Color", token) is Color val) || !(val.a > 0f)) { return fallback; } return val; } internal static TMP_FontAsset Font(string kind, TMP_FontAsset fallback) { object obj = Call("Font", kind); return (TMP_FontAsset)(((obj is TMP_FontAsset) ? obj : null) ?? fallback); } internal static Sprite Rounded(int radius) { object obj = Call("Rounded", radius); return (Sprite)((obj is Sprite) ? obj : null); } internal static Sprite Ring(int radius) { object obj = Call("Ring", radius); return (Sprite)((obj is Sprite) ? obj : null); } internal static Sprite Icon(string name) { object obj = Call("Icon", name); return (Sprite)((obj is Sprite) ? obj : null); } } internal static class Log { private static ManualLogSource _s; internal static void Bind(ManualLogSource s) { if (_s == null) { _s = s; } } internal static void Info(string m) { ManualLogSource s = _s; if (s != null) { s.LogInfo((object)m); } } internal static void Warn(string m) { ManualLogSource s = _s; if (s != null) { s.LogWarning((object)m); } } } [BepInPlugin("jatify.mapteleport", "MapTeleport", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "jatify.mapteleport"; internal unsafe static bool CanAdmin { get { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance == (Object)null) { return false; } if (ZNet.instance.LocalPlayerIsAdminOrHost()) { return true; } PlatformUserID userId = UserInfo.GetLocalUser().UserId; List<string> adminList = ZNet.instance.GetAdminList(); if (adminList != null) { if (!adminList.Contains(((object)(*(PlatformUserID*)(&userId))/*cast due to .constrained prefix*/).ToString())) { return adminList.Contains(userId.m_userID.ToString()); } return true; } return false; } } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log.Bind(((BaseUnityPlugin)this).Logger); new Harmony("jatify.mapteleport").PatchAll(typeof(Plugin).Assembly); } private void Update() { Menu.Tick(); } private void OnDestroy() { Menu.Destroy(); } } [HarmonyPatch(typeof(Minimap), "RemovePinUnderPointer")] internal static class RightClick { private static void Prefix(Minimap __instance) { //IL_005b: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Traverse val = Traverse.Create((object)__instance); if (val.Method("GetClosestPinToCursor", Array.Empty<object>()).GetValue<PinData>() == null && Plugin.CanAdmin && !((Object)(object)Player.m_localPlayer == (Object)null)) { Vector3 value = val.Method("ScreenToWorldPoint", new Type[1] { typeof(Vector3) }, (object[])null).GetValue<Vector3>(new object[1] { ZInput.pointerPosition }); Menu.Open(__instance, value); } } } internal static class Menu { [CompilerGenerated] private static class <>O { public static UnityAction <0>__Teleport; } private const float W = 260f; private const float H = 48f; private static RectTransform _root; private static Vector3 _target; private static Minimap _map; internal static bool IsOpen { get { if ((Object)(object)_root != (Object)null) { return ((Component)_root).gameObject.activeSelf; } return false; } } internal static void Open(Minimap map, Vector3 world) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //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) //IL_005c: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_00d8: Unknown result type (might be due to invalid IL or missing references) Destroy(); _map = map; _target = world; Build(map, world); RectTransform val = (RectTransform)((Transform)_root).parent; Canvas componentInParent = ((Component)val).GetComponentInParent<Canvas>(); Camera val2 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); Vector2 val3 = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(val, Vector2.op_Implicit(ZInput.pointerPosition), val2, ref val3); Rect rect = val.rect; val3.x = Mathf.Clamp(val3.x + 8f, ((Rect)(ref rect)).xMin + 4f, ((Rect)(ref rect)).xMax - 260f - 4f); val3.y = Mathf.Clamp(val3.y - 8f, ((Rect)(ref rect)).yMin + 48f + 4f, ((Rect)(ref rect)).yMax - 4f); _root.anchoredPosition = val3; } internal static void Close() { if ((Object)(object)_root != (Object)null) { ((Component)_root).gameObject.SetActive(false); } } internal static void Destroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)((Component)_root).gameObject); } _root = null; } private static void Build(Minimap map, Vector3 world) { //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00e1: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0194: 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) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) bool jatify = JatifyLook.On; TMP_FontAsset fallback = (((Object)(object)map.m_biomeNameLarge != (Object)null) ? map.m_biomeNameLarge.font : TMP_Settings.defaultFontAsset); Color fill = JatifyLook.Color("glass", new Color(0.09f, 0.09f, 0.1f, 0.94f)); Color line = JatifyLook.Color("glassLine", new Color(1f, 1f, 1f, 0.15f)); Color fill2 = JatifyLook.Color("raised2", new Color(0.2f, 0.2f, 0.22f, 1f)); Color c = JatifyLook.Color("dim", new Color(0.75f, 0.75f, 0.78f)); GameObject val = new GameObject("MapTeleportCard", new Type[1] { typeof(RectTransform) }); _root = (RectTransform)val.transform; ((Transform)_root).SetParent(map.m_largeRoot.transform, false); RectTransform root = _root; RectTransform root2 = _root; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.5f); root2.anchorMax = val2; root.anchorMin = val2; _root.pivot = new Vector2(0f, 1f); _root.sizeDelta = new Vector2(260f, 48f); Canvas obj = val.AddComponent<Canvas>(); obj.overrideSorting = true; obj.sortingOrder = 32500; val.AddComponent<GraphicRaycaster>(); Box(_root, fill, line, 10, jatify); TextMeshProUGUI obj2 = Text((Transform)(object)_root, $"x {world.x:0} · z {world.z:0}", JatifyLook.Font("mono", fallback), 12f, c); Place(((TMP_Text)obj2).rectTransform, 12f, 0f, 120f, 48f); ((TMP_Text)obj2).alignment = (TextAlignmentOptions)4097; TextMeshProUGUI val3 = Text(null, "Teleport here", JatifyLook.Font("medium", fallback), 12.5f, Color.white); float num = 32f + ((TMP_Text)val3).GetPreferredValues().x + 12f; GameObject val4 = new GameObject("Teleport", new Type[1] { typeof(RectTransform) }); RectTransform val5 = (RectTransform)val4.transform; ((Transform)val5).SetParent((Transform)(object)_root, false); Place(val5, 252f - num, 8f, num, 32f); Image targetGraphic = Box(val5, fill2, line, 8, jatify); Button obj3 = val4.AddComponent<Button>(); ((Selectable)obj3).targetGraphic = (Graphic)(object)targetGraphic; ColorBlock colors = ((Selectable)obj3).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(1.25f, 1.25f, 1.25f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.85f, 0.85f, 0.85f); ((ColorBlock)(ref colors)).selectedColor = Color.white; ((Selectable)obj3).colors = colors; ButtonClickedEvent onClick = obj3.onClick; object obj4 = <>O.<0>__Teleport; if (obj4 == null) { UnityAction val6 = Teleport; <>O.<0>__Teleport = val6; obj4 = (object)val6; } ((UnityEvent)onClick).AddListener((UnityAction)obj4); object obj5; if (!((Object)(object)ZNetScene.instance != (Object)null)) { obj5 = null; } else { GameObject prefab = ZNetScene.instance.GetPrefab("portal_wood"); obj5 = ((prefab == null) ? null : prefab.GetComponent<Piece>()?.m_icon); } Sprite val7 = (Sprite)obj5; if ((Object)(object)val7 != (Object)null) { Image obj6 = Img((Transform)(object)val5, val7, Color.white); obj6.preserveAspect = true; Place(((Graphic)obj6).rectTransform, 8f, 7f, 18f, 18f); } ((TMP_Text)val3).transform.SetParent((Transform)(object)val5, false); Place(((TMP_Text)val3).rectTransform, 32f, 0f, num - 32f, 32f); ((TMP_Text)val3).alignment = (TextAlignmentOptions)4097; } private static Image Box(RectTransform parent, Color fill, Color line, int radius, bool jatify) { //IL_0019: 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_003d: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) Sprite val = (jatify ? JatifyLook.Ring(radius) : null); Vector2 offsetMin; if ((Object)(object)val != (Object)null) { Image val2 = Img((Transform)(object)parent, val, line); val2.type = (Type)1; ((Graphic)val2).rectTransform.anchorMin = Vector2.zero; ((Graphic)val2).rectTransform.anchorMax = Vector2.one; RectTransform rectTransform = ((Graphic)val2).rectTransform; offsetMin = (((Graphic)val2).rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; } Image val3 = Img((Transform)(object)parent, jatify ? JatifyLook.Rounded(radius) : null, fill); val3.type = (Type)1; ((Graphic)val3).raycastTarget = true; ((Graphic)val3).rectTransform.anchorMin = Vector2.zero; ((Graphic)val3).rectTransform.anchorMax = Vector2.one; RectTransform rectTransform2 = ((Graphic)val3).rectTransform; offsetMin = (((Graphic)val3).rectTransform.offsetMax = Vector2.zero); rectTransform2.offsetMin = offsetMin; if ((Object)(object)val != (Object)null) { ((Component)val3).transform.SetAsFirstSibling(); } return val3; } private static Image Img(Transform parent, Sprite s, Color c) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Image", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); Image obj = val.AddComponent<Image>(); obj.sprite = s; ((Graphic)obj).color = c; ((Graphic)obj).raycastTarget = false; return obj; } private static TextMeshProUGUI Text(Transform parent, string s, TMP_FontAsset font, float size, Color c) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text", new Type[1] { typeof(RectTransform) }); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, false); } TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)obj).font = font; ((TMP_Text)obj).fontSize = size; ((Graphic)obj).color = c; ((TMP_Text)obj).text = s; ((Graphic)obj).raycastTarget = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; return obj; } private static void Place(RectTransform r, float x, float y, float w, float h) { //IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); r.pivot = val; Vector2 anchorMin = (r.anchorMax = val); r.anchorMin = anchorMin; r.anchoredPosition = new Vector2(x, 0f - y); r.sizeDelta = new Vector2(w, h); } private static void Teleport() { //IL_0098: 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) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) Close(); Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && Plugin.CanAdmin) { float num = ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetHeight(_target.x, _target.z) : _target.y); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(_target.x, Mathf.Max(num, ((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.m_waterLevel : 30f) + 2f, _target.z); Log.Info($"teleport to x={val.x:0} z={val.z:0}"); Minimap instance = Minimap.instance; if (instance != null) { instance.SetMapMode((MapMode)1); } ((Character)localPlayer).TeleportTo(val, ((Component)localPlayer).transform.rotation, true); } } internal static void Tick() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen) { return; } if ((Object)(object)_map == (Object)null || (Object)(object)Minimap.instance == (Object)null || !Minimap.IsOpen() || Input.GetKeyDown((KeyCode)27)) { Close(); } else if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { Canvas componentInParent = ((Component)_root).GetComponentInParent<Canvas>(); Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (!RectTransformUtility.RectangleContainsScreenPoint(_root, Vector2.op_Implicit(ZInput.pointerPosition), val)) { Close(); } } } } }