示例#1
0
        /// <summary>
        ///     CLIENT SIDE: Initially pull portals after SetMapData on Minimap
        /// </summary>
        private static void UpdatePortalPins(On.Minimap.orig_SetMapData orig, Minimap self, byte[] data)
        {
            orig(self, data);

            if (ZNet.instance.IsServerInstance())
            {
                return;
            }

            if (!ConfigUtil.Get <bool>("Map", "showPortalsOnMap"))
            {
                return;
            }

            if (ZNet.instance.IsLocalInstance())
            {
                Logger.LogMessage("Initializing portals");
                UpdatePins(PortalList.GetPortals());
            }

            if (ZNet.instance.IsClientInstance())
            {
                Logger.LogMessage("Sending portal sync request to server");
                ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(RPC_Veilheim_TeleporterSyncInit), new ZPackage());
            }
        }
示例#2
0
        /// <summary>
        ///     RPC to handle initial sync to a new peer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="teleporterZPackage"></param>
        public static void RPC_Veilheim_TeleporterSyncInit(long sender, ZPackage teleporterZPackage)
        {
            // SERVER SIDE
            if (ZNet.instance.IsServerInstance() || ZNet.instance.IsLocalInstance())
            {
                Logger.LogMessage($"Sending portal data to peer #{sender}");

                var portals = PortalList.GetPortals();

                if (ZNet.instance.IsLocalInstance())
                {
                    UpdatePins(portals);
                }

                var package = portals.ToZPackage();
                ZRoutedRpc.instance.InvokeRoutedRPC(sender, nameof(RPC_Veilheim_TeleporterSyncInit), package);
            }

            // CLIENT SIDE
            if (ZNet.instance.IsClientInstance())
            {
                if (teleporterZPackage != null && teleporterZPackage.Size() > 0 && sender == ZRoutedRpc.instance.GetServerPeerID())
                {
                    // Read package and create pins from portal list
                    Logger.LogMessage("Received portal data from server");

                    portalsFromServer = PortalList.FromZPackage(teleporterZPackage);

                    UpdatePins(portalsFromServer);
                }
            }
        }
示例#3
0
 public void OnPointerClick(PointerEventData eventData)
 {
     Logger.LogMessage(eventData.GetObjectString());
 }