コード例 #1
0
        void OnJoinResult(MyPacket packet)
        {
           JoinResultMsg msg = ReplicationLayer.OnJoinResult(packet);

           OnUserJoined(ref msg);
        }
コード例 #2
0
 void OnClientConnected(MyPacket packet)
 {
     ConnectedClientDataMsg msg = ReplicationLayer.OnClientConnected(packet);
     OnConnectedClient(ref msg);
 }
コード例 #3
0
 void OnWorldBattleData(MyPacket packet)
 {
     ServerBattleDataMsg msg = ReplicationLayer.OnWorldBattleData(packet);
     OnServerBattleData(ref msg);
 }
コード例 #4
0
 void OnReplicationDestroy(MyPacket packet)
 {
     ReplicationLayer.ProcessReplicationDestroy(packet);
 }
コード例 #5
0
 void OnReplicationCreate(MyPacket packet)
 {
     while (MyEntities.HasEntitiesToDelete())
     {
         MyEntities.DeleteRememberedEntities();
     }
     ReplicationLayer.ProcessReplicationCreate(packet);
 }
コード例 #6
0
        private void ProcessEvent( MyPacket packet )
        {
            if ( _networkHandlers.Count == 0 )
            {
                ((MyReplicationLayer)MyMultiplayer.ReplicationLayer).ProcessEvent(packet);
                return;
            }

            //magic: DO NOT TOUCH
            BitStream stream = new BitStream();
            stream.ResetRead( packet );

            NetworkId networkId = stream.ReadNetworkId();
            //this value is unused, but removing this line corrupts the rest of the stream
            NetworkId blockedNetworkId = stream.ReadNetworkId();
            uint eventId = (uint)stream.ReadByte();

            CallSite site;
            IMyNetObject sendAs;
            object obj;
            if ( networkId.IsInvalid ) // Static event
            {
                site = m_typeTable.StaticEventTable.Get( eventId );
                sendAs = null;
                obj = null;
            }
            else // Instance event
            {
                sendAs = ( (MyReplicationLayer)MyMultiplayer.ReplicationLayer ).GetObjectByNetworkId( networkId );
                if ( sendAs == null )
                {
                    return;
                }
                var typeInfo = m_typeTable.Get( sendAs.GetType() );
                int eventCount = typeInfo.EventTable.Count;
                if ( eventId < eventCount ) // Directly
                {
                    obj = sendAs;
                    site = typeInfo.EventTable.Get( eventId );
                }
                else // Through proxy
                {
                    obj = ( (IMyProxyTarget)sendAs ).Target;
                    typeInfo = m_typeTable.Get( obj.GetType() );
                    site = typeInfo.EventTable.Get( eventId - (uint)eventCount ); // Subtract max id of Proxy
                }
            }

            #if DEBUG
            if ( ExtenderOptions.IsDebugging )
            {
                if ( !site.MethodInfo.Name.Contains( "SyncPropertyChanged" ) && !site.MethodInfo.Name.Contains( "OnSimulationInfo" ) )
                    ApplicationLog.Error( $"Caught event {site.MethodInfo.Name} from user {PlayerMap.Instance.GetFastPlayerNameFromSteamId( packet.Sender.Value )}:{packet.Sender.Value}" );
            }
            #endif
            //we're handling the network live in the game thread, this needs to go as fast as possible
            bool handled = false;
            Parallel.ForEach( _networkHandlers, handler =>
                                                {
                                                    if ( handler.CanHandle( site ) )
                                                        handled |= handler.Handle( packet.Sender.Value, site, stream, obj );
                                                } );

            if ( !handled )
                ( (MyReplicationLayer)MyMultiplayer.ReplicationLayer ).ProcessEvent( packet );
        }
コード例 #7
0
        void OnValueChanged(MyPacket packet)
        {

        }