Exemple #1
0
            static bool Prefix(TeleportWorld __instance)
            {
                Player closestPlayer = Player.GetClosestPlayer(__instance.m_proximityRoot.position, __instance.m_activationRange);

                __instance.m_target_found.SetActive(closestPlayer && closestPlayer.IsTeleportable());
                return(false);
            }
Exemple #2
0
            static bool Prefix(TeleportWorld __instance, ref string __result)
            {
                string text = __instance.GetText();

                __result = Localization.instance.Localize(string.Concat(new string[] { configPortalNamePrefix.Value, text, "\n[<color=yellow><b>$KEY_Use</b></color>] $piece_portal_settag" }));
                return(false);
            }
Exemple #3
0
        /// <summary>
        ///     CLIENT SIDE: Creates a <see cref="PortalSelectionGUI" /> when interacting with a portal
        /// </summary>
        private static bool ShowPortalSelection(On.TeleportWorld.orig_Interact orig, TeleportWorld self, Humanoid human, bool hold)
        {
            bool result = orig(self, human, hold);

            // only act on clients
            if (ZNet.instance.IsServerInstance())
            {
                return(result);
            }

            // must be enabled
            if (!ConfigUtil.Get <bool>("Map", "showPortalSelection"))
            {
                return(result);
            }

            // i like my personal space
            if (!PrivateArea.CheckAccess(self.transform.position) || hold)
            {
                return(result);
            }

            PortalSelectionGUI.OpenPortalSelection();

            return(result);
        }
Exemple #4
0
        public void RemovePiece(Piece piece)
        {
            m_pieces.Remove(piece);
            TeleportWorld component3 = piece.GetComponent <TeleportWorld>();

            if ((bool)component3)
            {
                m_portals.Remove(piece);
            }
        }
        private static bool Prefix(ref TeleportWorld __instance, ref Player player)
        {
            if (Configuration.Current.Game.IsEnabled && Configuration.Current.Game.disablePortals)
            {
                MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, "Portals have been disabled on this Server.");
                return(false);
            }

            return(true);
        }
Exemple #6
0
 private static void Postfix(TeleportWorld __instance, long sender, string tag)
 {
     try
     {
         PostfixEvent?.Invoke(__instance, sender, tag);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message + Environment.NewLine + ex.StackTrace);
     }
 }
Exemple #7
0
 static void Postfix(TeleportWorld __instance, ZNetView ___m_nview, string text)
 {
     if (___m_nview != null)
     {
         tp_list.TryGetValue(___m_nview.GetZDO(), out Minimap.PinData temp_data);
         if (temp_data != null)
         {
             temp_data.m_name = GetLocalizedString(configPortalNamePrefix.Value) + text;
         }
     }
 }
Exemple #8
0
 private static void Postfix(TeleportWorld __instance, Humanoid human, bool hold)
 {
     try
     {
         PostfixEvent?.Invoke(__instance, human, hold);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message + Environment.NewLine + ex.StackTrace);
     }
 }
Exemple #9
0
            static void Postfix(TeleportWorld __instance, ref ZNetView ___m_nview, ref bool __result)
            {
                lastPortalInteracted = __instance;
                lastPortalZNetView   = ___m_nview;

                if (!__result)
                {
                    return;
                }

                if (dropdownHolder == null)
                {
                    InitializeDropdownHolder();
                }
                portalList.Clear();
                dropdown.onValueChanged.RemoveAllListeners();
                dropdown.onValueChanged.AddListener(delegate
                {
                    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");

                dropdown.options.Add(new Dropdown.OptionData("No destination"));
                var tmpPortalList = new List <ZDO>();

                ZDOMan.instance.GetAllZDOsWithPrefab(Game.instance.m_portalPrefab.name, tmpPortalList);
                // 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;
                    }
                    index += 1;
                }
                if (targetZDOID == ZDOID.None)
                {
                    dropdown.value = 0;
                }
                dropdownHolder.SetActive(true);
            }
Exemple #10
0
            private static void Awake_Postfix(TeleportWorld __instance)
            {
                // If enabled == false, this is probably a build placement ghost rather than an actual portal. It will not have a ZDO.
                if (__instance.enabled)
                {
                    UpdateActivationRange(__instance);

                    // Every time a portal is loaded (like by a player loading the area it is in), a new instance is created.
                    // However, the same portal will always have the same ZDOID. So, we can just replace the instance.
                    sPortals[__instance.GetComponent <ZNetView>().GetZDO().m_uid] = __instance;
                }
            }
 static void Postfix(TeleportWorld __instance)
 {
     if (!modEnabled.Value)
     {
         return;
     }
     if (customSFX.ContainsKey("portal"))
     {
         AudioSource source = __instance.GetComponentInChildren <AudioSource>();
         source.clip = customSFX["portal"];
         source.gameObject.SetActive(false);
         source.gameObject.SetActive(true);
     }
 }
Exemple #12
0
        public void AddPiece(Piece piece)
        {
            m_pieces.Add(piece);

            if (piece.TryGetComponent(out Pulley pulley))
            {
                m_baseRoot.AddPulley(pulley);
            }

            if (piece.TryGetComponent(out WearNTear wearNTear))
            {
                wearNTear.m_onDestroyed += () => OnDestroyed(piece);
            }

            TeleportWorld component3 = piece.GetComponent <TeleportWorld>();

            if ((bool)component3)
            {
                m_portals.Add(piece);
            }
            MeshRenderer[] componentsInChildren = piece.GetComponentsInChildren <MeshRenderer>(includeInactive: true);
            MeshRenderer[] array = componentsInChildren;
            foreach (MeshRenderer meshRenderer in array)
            {
                if ((bool)meshRenderer.sharedMaterial)
                {
                    Material[] sharedMaterials = meshRenderer.sharedMaterials;
                    for (int j = 0; j < sharedMaterials.Length; j++)
                    {
                        Material material = new Material(sharedMaterials[j]);
                        material.SetFloat("_RippleDistance", 0f);
                        material.SetFloat("_ValueNoise", 0f);
                        sharedMaterials[j] = material;
                    }
                    meshRenderer.sharedMaterials = sharedMaterials;
                }
            }
            Rigidbody[] componentsInChildren2 = piece.GetComponentsInChildren <Rigidbody>();
            for (int k = 0; k < componentsInChildren2.Length; k++)
            {
                if (componentsInChildren2[k].isKinematic)
                {
#if DEBUG
                    Jotunn.Logger.LogWarning(GetZDOID() + " Destroying rigidbody: " + componentsInChildren2[k]);
#endif
                    Destroy(componentsInChildren2[k]);
                }
            }
        }
Exemple #13
0
        private static void UpdateActivationRange(TeleportWorld portal)
        {
            // This if check is to see if the portal instance is actually loaded. If it isn't then we don't care. Next time
            // it is laoded, a new instance will be created.
            if (portal)
            {
                portal.m_activationRange = ActivationRange.Value;

                // Activation is triggered when a player is within a radius of the proximity root. The root needs to be moved as
                // the range changes so that the defined circle is in front of the portal object with its edge meeting the portal.
                // Note: Because the check uses a circle, the activation zone gets weirder as the range gets larger.
                Transform root = portal.m_proximityRoot;
                root.localPosition = new Vector3(root.localPosition.x, root.localPosition.y, ActivationRange.Value * 0.5f + 0.25f);
            }
        }
Exemple #14
0
        private static void Postfix(TeleportWorld __instance, string __result)
        {
            string portalName = __instance.GetText();

            if (Configuration.Current.Game.IsEnabled && Configuration.Current.Game.bigPortalNames)
            {
                __result = Localization.instance.Localize(string.Concat(new string[]
                {
                    "$piece_portal $piece_portal_tag:",
                    " ",
                    "[", portalName, "]"
                }));

                MessageHud.instance.ShowMessage(MessageHud.MessageType.Center, __result, 0, null);
                return;
            }
            return;
        }
Exemple #15
0
        private static bool Prefix(TeleportWorld __instance)
        {
            var cancel = false;

            BlockingPrefixEvent?.Invoke(__instance, ref cancel);

            if (!cancel)
            {
                try
                {
                    PrefixEvent?.Invoke(__instance);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.Message + Environment.NewLine + ex.StackTrace);
                }
            }

            return(!cancel);
        }
Exemple #16
0
        public static void ResyncAfterTagChange(TeleportWorld instance, long sender, string tag)
        {
            if (ZNet.instance.IsServerInstance())
            {
                return;
            }

            Logger.LogInfo("Portal tag changed");

            if (ZNet.instance.IsLocalInstance())
            {
                Logger.LogInfo("Sending portal sync request to server");

                // Send trigger to server
                ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(RPC_TeleporterSync), new ZPackage());
            }

            if (ZNet.instance.IsClientInstance())
            {
                Logger.LogDebug("Forcing ZDO to server");

                // Force sending ZDO to server
                var temp = instance.m_nview.GetZDO();

                ZDOMan.instance.GetZDO(temp.m_uid);

                ZDOMan.instance.GetPeer(ZRoutedRpc.instance.GetServerPeerID()).ForceSendZDO(temp.m_uid);

                Logger.LogInfo("Sending deferred portal sync request to server");

                Task.Factory.StartNew(() =>
                {
                    // Wait for ZDO to be sent else server won't have accurate information to send back
                    Thread.Sleep(5000);

                    // Send trigger to server
                    ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(RPC_TeleporterSync), new ZPackage());
                });
            }
        }
Exemple #17
0
        public static void ShowPortalSelection(TeleportWorld instance, Humanoid human, bool hold)
        {
            // only act on clients
            if (ZNet.instance.IsServerInstance())
            {
                return;
            }

            // must be enabled
            if (!Configuration.Current.Map.IsEnabled || !Configuration.Current.Map.showPortalSelection)
            {
                return;
            }

            // i like my personal space
            if (!PrivateArea.CheckAccess(instance.transform.position) || hold)
            {
                return;
            }

            PortalSelectionGUI.OpenPortalSelection();
        }
Exemple #18
0
            static bool Prefix(TeleportWorld __instance, ref ZNetView ___m_nview, ref string __result)
            {
                string destPortalTag = "None";
                string tag           = __instance.GetText();

                if (tag == "")
                {
                    tag = "Empty tag";
                }
                if (___m_nview == null || !___m_nview.IsValid())
                {
                    Debug.LogError("HoverTextPatch: ___m_nview is not valid");
                }
                else
                {
                    ZDOID targetZDOID = ___m_nview.GetZDO().GetZDOID("target");
                    if (!targetZDOID.IsNone())
                    {
                        var destPortalZDO = ZDOMan.instance.GetZDO(targetZDOID);
                        if (destPortalZDO == null || !destPortalZDO.IsValid())
                        {
                            Debug.Log("HoverText: destPortalZDO is null or invalid");
                            destPortalTag = "None";
                            // Reset the target since it's bad...
                            Debug.Log("HoverText: Clearing out the target");
                            ___m_nview.GetZDO().Set("target", ZDOID.None);
                            ZDOMan.instance.ForceSendZDO(___m_nview.GetZDO().m_uid);
                        }
                        else
                        {
                            destPortalTag = destPortalZDO.GetString("tag", "Empty tag");
                        }
                    }
                }
                __result = Localization.instance.Localize($"Portal Tag: {tag}\nDestination Portal Tag: {destPortalTag}\n[<color=yellow><b>$KEY_Use</b></color>] Configure Portal");
                return(false);
            }
 private static void Prefix(TeleportWorld __instance)
 {
     Events.Client.DOOR.CloseTrackedDoor();
 }
 public static void Postfix(ref TeleportWorld __instance, Player player)
 {
     ArtemisGsiPlugin.ArtemisWebClient.SendEvent("teleport", "{}");
 }