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 PortalUniversal v1.0.5
PortalUniversal.dll
Decompiled 15 hours agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace PortalUniversal; [BepInPlugin("yuri.PortalUniversal", "Portal Universal", "1.0.4")] public class Plugin : BaseUnityPlugin { public static ConfigEntry<bool> Ligado; public static bool Escolhendo; public static ZDOID Origem; public static float Saida = 2f; public static float Liberar; public static float IgnorarDuplo; private static readonly Dictionary<ZDOID, PinData> marcas = new Dictionary<ZDOID, PinData>(); private static float proxima; private static bool avisou; private static MethodInfo centro; private static MethodInfo pontoTela; private static MethodInfo pinoPerto; private static PropertyInfo raioProp; private void Awake() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) Ligado = ((BaseUnityPlugin)this).Config.Bind<bool>("Geral", "Ligado", true, "Entrar no portal abre o mapa para escolher o destino. Não muda o nome. Só no seu jogo."); centro = typeof(Minimap).GetMethod("CenterMap", BindingFlags.Instance | BindingFlags.NonPublic); pontoTela = typeof(Minimap).GetMethod("ScreenToWorldPoint", BindingFlags.Instance | BindingFlags.NonPublic); pinoPerto = typeof(Minimap).GetMethod("GetClosestPin", BindingFlags.Instance | BindingFlags.NonPublic); raioProp = typeof(Minimap).GetProperty("PinInteractRadius", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); new Harmony("yuri.PortalUniversal").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Portal Universal 1.0.4"); } private void Update() { if (Ligado == null || !Ligado.Value) { Apagar(); Escolhendo = false; } else if (ZDOMan.instance != null && !((Object)(object)Minimap.instance == (Object)null) && !(Time.time < proxima)) { proxima = Time.time + 1f; Sincronizar(); } } public static void Abrir(TeleportWorld portal, Player jogador) { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) Saida = (((Object)(object)portal != (Object)null) ? portal.m_exitDistance : 2f); if (Saida < 0.5f) { Saida = 2f; } Origem = PortalPerto(((Component)jogador).transform.position); Sincronizar(); int num = 0; foreach (ZDOID key in marcas.Keys) { ZDOID current = key; if (!((ZDOID)(ref current)).Equals(Origem)) { num++; } } if (num == 0) { Avisar(jogador, "Não tem outro portal."); return; } Escolhendo = true; Minimap.instance.SetMapMode((MapMode)2); if (centro != null) { centro.Invoke(Minimap.instance, new object[1] { ((Component)jogador).transform.position }); } Avisar(jogador, "Selecione o portal no mapa."); } public static bool Bloqueado(TeleportWorld portal, Player jogador) { if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey((GlobalKeys)32)) { Avisar(jogador, "$msg_blocked"); return true; } if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey((GlobalKeys)33)) { bool flag = false; if ((Object)(object)RandEventSystem.instance != (Object)null) { string bossEvent = RandEventSystem.instance.GetBossEvent(); flag = bossEvent != null && bossEvent.Length > 0; } if (!flag) { float num = 0f; flag = ZoneSystem.instance.GetGlobalKey((GlobalKeys)47, ref num) && num > 0f; } if (flag) { Avisar(jogador, "$msg_blockedbyboss"); return true; } } bool flag2 = (Object)(object)portal != (Object)null && portal.m_allowAllItems; if (!((Humanoid)jogador).IsTeleportable(flag2)) { Avisar(jogador, "$msg_noteleport"); return true; } return false; } public static void Escolher() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00cd: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: 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_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Minimap instance = Minimap.instance; if ((Object)(object)localPlayer == (Object)null || (Object)(object)instance == (Object)null || pontoTela == null || pinoPerto == null || ZDOMan.instance == null) { return; } object obj = ZInput.pointerPosition; Vector3 mundo = (Vector3)pontoTela.Invoke(instance, new object[1] { obj }); float num = 30f; if (raioProp != null) { num = (float)raioProp.GetValue(instance, null); } if (num < 8f) { num = 8f; } ZDOID val = MarcaPerto(mundo, num); if (((ZDOID)(ref val)).Equals(ZDOID.None)) { Avisar(localPlayer, "Clique na marca do portal."); return; } List<ZDO> portalList = ZDOMan.instance.GetPortalList(); ZDO val2 = null; if (portalList != null) { for (int i = 0; i < portalList.Count; i++) { if (portalList[i] != null && ((ZDOID)(ref portalList[i].m_uid)).Equals(val)) { val2 = portalList[i]; break; } } } if (val2 == null) { Avisar(localPlayer, "Esse portal sumiu."); Sincronizar(); return; } if (((ZDOID)(ref val)).Equals(Origem) || Vector3.Distance(val2.GetPosition(), ((Component)localPlayer).transform.position) < 4f) { Avisar(localPlayer, "Você já está neste portal."); return; } Quaternion rotation = val2.GetRotation(); Vector3 val3 = val2.GetPosition() + rotation * Vector3.forward * Saida + Vector3.up; if (((Character)localPlayer).TeleportTo(val3, rotation, true)) { if ((Object)(object)Game.instance != (Object)null) { Game.instance.IncrementPlayerStat((PlayerStatType)15, 1f, false); } Escolhendo = false; IgnorarDuplo = Time.time + 0.5f; Liberar = Time.time + 2f; instance.SetMapMode((MapMode)1); } } private static void Sincronizar() { //IL_00cc: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Minimap.instance == (Object)null || ZDOMan.instance == null) { return; } List<ZDO> portalList = ZDOMan.instance.GetPortalList(); Dictionary<ZDOID, ZDO> dictionary = new Dictionary<ZDOID, ZDO>(); if (portalList != null) { for (int i = 0; i < portalList.Count; i++) { ZDO val = portalList[i]; if (val != null && !((ZDOID)(ref val.m_uid)).Equals(ZDOID.None) && !dictionary.ContainsKey(val.m_uid)) { dictionary.Add(val.m_uid, val); } } } List<ZDOID> list = new List<ZDOID>(); foreach (KeyValuePair<ZDOID, PinData> marca in marcas) { if (!dictionary.ContainsKey(marca.Key)) { list.Add(marca.Key); } } for (int i = 0; i < list.Count; i++) { if (marcas.TryGetValue(list[i], out var value) && value != null) { Minimap.instance.RemovePin(value); } marcas.Remove(list[i]); } foreach (KeyValuePair<ZDOID, ZDO> item in dictionary) { string text = Nome(item.Value); Vector3 position = item.Value.GetPosition(); if (marcas.TryGetValue(item.Key, out var value2) && value2 != null) { value2.m_pos = position; value2.m_name = text; value2.m_doubleSize = true; continue; } value2 = Minimap.instance.AddPin(position, (PinType)3, text, false, false, 0L, PlatformUserID.None); if (value2 != null) { value2.m_doubleSize = true; marcas[item.Key] = value2; } } FieldInfo field = typeof(Minimap).GetField("m_pinUpdateRequired", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(Minimap.instance, true); } } catch (Exception ex) { if (!avisou) { avisou = true; Debug.LogWarning((object)("Portal Universal: " + ex.Message)); } } } private static void Apagar() { if (marcas.Count == 0 || (Object)(object)Minimap.instance == (Object)null) { marcas.Clear(); return; } foreach (KeyValuePair<ZDOID, PinData> marca in marcas) { if (marca.Value != null) { Minimap.instance.RemovePin(marca.Value); } } marcas.Clear(); } private static ZDOID MarcaPerto(Vector3 mundo, float raio) { //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_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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) ZDOID result = ZDOID.None; float num = raio; foreach (KeyValuePair<ZDOID, PinData> marca in marcas) { if (marca.Value != null) { float num2 = marca.Value.m_pos.x - mundo.x; float num3 = marca.Value.m_pos.z - mundo.z; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); if (num4 < num) { num = num4; result = marca.Key; } } } return result; } private static ZDOID PortalPerto(Vector3 pos) { //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_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_009d: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) ZDOID result = ZDOID.None; float num = 8f; if (ZDOMan.instance == null) { return result; } List<ZDO> portalList = ZDOMan.instance.GetPortalList(); if (portalList == null) { return result; } for (int i = 0; i < portalList.Count; i++) { ZDO val = portalList[i]; if (val != null) { float num2 = Vector3.Distance(val.GetPosition(), pos); if (num2 < num) { num = num2; result = val.m_uid; } } } return result; } private static string Nome(ZDO zdo) { string text = zdo.GetString(ZDOVars.s_tag, ""); if (text == null) { return "Portal"; } text = text.Trim(); if (text.Length == 0) { return "Portal"; } return text; } private static void Avisar(Player jogador, string texto) { if ((Object)(object)jogador != (Object)null) { ((Character)jogador).Message((MessageType)2, texto, 0, (Sprite)null, false); } } } [HarmonyPatch(typeof(TeleportWorld), "Teleport")] public static class AoEntrar { private static bool Prefix(TeleportWorld __instance, Player player) { if (Plugin.Ligado == null || !Plugin.Ligado.Value) { return true; } if ((Object)(object)player == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return true; } if (Game.m_noMap) { return true; } if (Time.time < Plugin.Liberar || ((Character)player).IsTeleporting()) { return false; } if (Plugin.Bloqueado(__instance, player)) { return false; } if ((Object)(object)Minimap.instance == (Object)null || ZDOMan.instance == null) { return true; } Plugin.Abrir(__instance, player); return false; } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] public static class AoClicar { private static bool Prefix() { if (!Plugin.Escolhendo) { return true; } Plugin.Escolher(); return false; } } [HarmonyPatch(typeof(Minimap), "OnMapDblClick")] public static class AoDuplo { private static bool Prefix() { if (Plugin.Escolhendo || Time.time < Plugin.IgnorarDuplo) { return false; } return true; } } [HarmonyPatch(typeof(Minimap), "SetMapMode")] public static class AoFechar { private static void Postfix(MapMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)mode != 2) { Plugin.Escolhendo = false; } } }