Veilheim/Map/PortalsOnMap.cs
/// <summary>
///     RPC to handle sync to all peers
/// </summary>
/// <param name="sender"></param>
/// <param name="teleporterZPackage"></param>
RPC to handle sync to all peers
RPC to handle sync to all peers
public static void RPC_Veilheim_TeleporterSync(long sender, ZPackage teleporterZPackage)
        {
            if (ZNet.instance.IsServerInstance() || ZNet.instance.IsLocalInstance())
            {
                Logger.LogMessage("Sending portal data to all peers");
                var portals = PortalList.GetPortals();
                if (ZNet.instance.IsLocalInstance())
                {
                    UpdatePins(portals);
                }
                var package = portals.ToZPackage();
                foreach (var peer in ZNet.instance.m_peers)
                {
                    if (!peer.m_server)
                    {
                        Logger.LogInfo($"Sending portal data to peer #{peer.m_uid}");
                        ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, nameof(RPC_Veilheim_TeleporterSync), package);
                    }
                }
            }
            if (ZNet.instance.IsClientInstance())
            {
                if (teleporterZPackage != null && teleporterZPackage.Size() > 0 && sender == ZRoutedRpc.instance.GetServerPeerID())
                {
                    Logger.LogMessage("Received portal data from server");
                    portalsFromServer = PortalList.FromZPackage(teleporterZPackage);
                    UpdatePins(portalsFromServer);
                }
            }
        }
public static void RPC_Veilheim_TeleporterSync ( long sender , ZPackage teleporterZPackage ) { if ( ZNet . instance . IsServerInstance ( ) || ZNet . instance . IsLocalInstance ( ) ) { Logger . LogMessage ( " " ) ; var portals = PortalList . GetPortals ( ) ; if ( ZNet . instance . IsLocalInstance ( ) ) { UpdatePins ( portals ) ; } var package = portals . ToZPackage ( ) ; foreach ( var peer in ZNet . instance . m_peers ) { if ( ! peer . m_server ) { Logger . LogInfo ( $" Sending portal data to peer # { peer . m_uid } " ) ; ZRoutedRpc . instance . InvokeRoutedRPC ( peer . m_uid , nameof ( RPC_Veilheim_TeleporterSync ) , package ) ; } } } if ( ZNet . instance . IsClientInstance ( ) ) { if ( teleporterZPackage != null && teleporterZPackage . Size ( ) > 0 && sender == ZRoutedRpc . instance . GetServerPeerID ( ) ) { Logger . LogMessage ( " " ) ; portalsFromServer = PortalList . FromZPackage ( teleporterZPackage ) ; UpdatePins ( portalsFromServer ) ; } } }
RPC to handle sync to all peers
RPC to handle sync to all peers
// SERVER SIDE // CLIENT SIDE // Read package and create pins from portal list
sender
long
None
teleporterZPackage
ZPackage
None