Veilheim/Map/PortalsOnMap.cs
/// <summary>
///     CLIENT SIDE: React to a placement of a portal
/// </summary>
CLIENT SIDE: React to a placement of a portal
CLIENT SIDE : React to a placement of a portal
private static bool AfterPlacingPortal(On.Player.orig_PlacePiece orig, Player self, Piece piece)
        {
            bool successful = orig(self, piece);
            if (ZNet.instance.IsServerInstance())
            {
                return successful;
            }
            if (successful && !piece.IsCreator() && piece.m_name == "$piece_portal")
            {
                Logger.LogInfo("Portal created");
                if (ZNet.instance.IsLocalInstance())
                {
                    Logger.LogInfo("Sending portal sync request to server");
                    ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(RPC_Veilheim_TeleporterSync), new ZPackage());
                }
                if (ZNet.instance.IsClientInstance())
                {
                    Logger.LogInfo("Sending deferred portal sync request to server");
                    Task.Factory.StartNew(() =>
                    {
                        Thread.Sleep(5000);
                        ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(RPC_Veilheim_TeleporterSync), new ZPackage());
                    });
                }
            }
            return successful;
        }
private static bool AfterPlacingPortal ( On . Player . orig_PlacePiece orig , Player self , Piece piece ) { bool successful = orig ( self , piece ) ; if ( ZNet . instance . IsServerInstance ( ) ) { return successful ; } if ( successful && ! piece . IsCreator ( ) && piece . m_name == " " ) { Logger . LogInfo ( " " ) ; if ( ZNet . instance . IsLocalInstance ( ) ) { Logger . LogInfo ( " " ) ; ZRoutedRpc . instance . InvokeRoutedRPC ( ZRoutedRpc . instance . GetServerPeerID ( ) , nameof ( RPC_Veilheim_TeleporterSync ) , new ZPackage ( ) ) ; } if ( ZNet . instance . IsClientInstance ( ) ) { Logger . LogInfo ( " " ) ; Task . Factory . StartNew ( ( ) => { Thread . Sleep ( 5000 ) ; ZRoutedRpc . instance . InvokeRoutedRPC ( ZRoutedRpc . instance . GetServerPeerID ( ) , nameof ( RPC_Veilheim_TeleporterSync ) , new ZPackage ( ) ) ; } ) ; } } return successful ; }
CLIENT SIDE: React to a placement of a portal
CLIENT SIDE : React to a placement of a portal
// Wait for ZDO to be sent else server won't have accurate information to send back // Send trigger to server
orig
On.Player.orig_PlacePiece
self
Player
piece
Piece