From f808955dd26300c50e71734286a0d8b32a62f34e Mon Sep 17 00:00:00 2001 From: Alex Sweet Date: Sat, 6 Mar 2021 03:37:21 -0800 Subject: [PATCH] Don't show current portal in dropdown --- AnyPortal.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/AnyPortal.cs b/AnyPortal.cs index 3e648ca..b0d1010 100644 --- a/AnyPortal.cs +++ b/AnyPortal.cs @@ -239,7 +239,7 @@ static void Postfix(TeleportWorld __instance, ref ZNetView ___m_nview, ref bool { lastPortalInteracted = __instance; lastPortalZNetView = ___m_nview; - + if (!__result) { return; @@ -256,6 +256,7 @@ static void Postfix(TeleportWorld __instance, ref ZNetView ___m_nview, ref bool DropdownValueChanged(dropdown); }); dropdown.options.Clear(); + ZDOID thisPortalZDOID = ___m_nview.GetZDO().m_uid; // If the portal currently has a target configured, make sure that is the value selected in the dropdown // Otherwise, set the dropdown value to 0 (No destination) ZDOID targetZDOID = ___m_nview.GetZDO().GetZDOID("target"); @@ -263,13 +264,16 @@ static void Postfix(TeleportWorld __instance, ref ZNetView ___m_nview, ref bool dropdown.options.Add(new Dropdown.OptionData("No destination")); var tmpPortalList = new List(); ZDOMan.instance.GetAllZDOsWithPrefab(Game.instance.m_portalPrefab.name, tmpPortalList); - portalList = tmpPortalList.OrderBy(zdo => zdo.GetString("tag")).ToList(); - + // Sort alphabetically by portal tag and exclude self + portalList = tmpPortalList.OrderBy(zdo => zdo.GetString("tag")).Where(zdo => zdo.m_uid != thisPortalZDOID).ToList(); int index = 0; foreach (ZDO portalZDO in portalList) { float distance = Vector3.Distance(__instance.transform.position, portalZDO.GetPosition()); - + if (distance == 0f) + { + continue; + } dropdown.options.Add(new Dropdown.OptionData($"\"{portalZDO.GetString("tag")}\" -- Distance: " + (int)distance)); if (portalZDO.m_uid == targetZDOID) dropdown.value = index + 1;