Exemplo n.º 1
0
        private static void GamerJoinedEventHandler(object sender, GamerJoinedEventArgs e)
        {
            NetworkGamer networkGamer = e.Gamer;

            if (Main.netMode == 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    UI uI = Main.ui[i];
                    if (uI.wasRemovedFromSessionWithoutOurConsent)
                    {
                        SignedInGamer signedInGamer = uI.signedInGamer;
                        if (signedInGamer != null && signedInGamer.Gamertag == networkGamer.Gamertag)
                        {
                            networkGamer.Tag = uI.player;
                            return;
                        }
                    }
                }
            }
            else if (!networkGamer.IsLocal)
            {
                Main.checkUserGeneratedContent = true;
            }
            int    j      = 0;
            Player player = null;

            if (Main.netMode != 1)
            {
                for (; playerSlots[j]; j++)
                {
                }
                playerSlots[j] = true;
            }
            if (networkGamer.IsLocal)
            {
                LocalNetworkGamer localNetworkGamer = (LocalNetworkGamer)networkGamer;
                SignedInGamer     signedInGamer2    = localNetworkGamer.SignedInGamer;
                UI uI2 = Main.ui[(int)signedInGamer2.PlayerIndex];
                uI2.localGamer = localNetworkGamer;
                if (Main.netMode != 1)
                {
                    uI2.JoinSession(j);
                    player        = (Player)(networkGamer.Tag = Main.player[j]);
                    player.client = null;
                    if (networkGamer.IsHost)
                    {
                        sessionReadyEvent.Set();
                    }
                    else
                    {
                        Main.JoinGame(uI2);
                    }
                }
                else
                {
                    gamersWaitingForPlayerId.Add(uI2);
                }
                if (gamer == null)
                {
                    gamer = localNetworkGamer;
                }
            }
            else if (Main.netMode == 2)
            {
                SetAsRemotePlayerSlot(j);
                NetClient netClient = null;
                for (int num = clients.Count - 1; num >= 0; num--)
                {
                    if (clients[num].machine == networkGamer.Machine)
                    {
                        netClient = clients[num];
                        break;
                    }
                }
                if (netClient == null)
                {
                    netClient = new NetClient(networkGamer);
                    clients.Add(netClient);
                    NetMessage.syncPlayers();
                }
                player = Main.player[j];
                netClient.GamerJoined(player);
                networkGamer.Tag = player;
                NetMessage.SendPlayerId(networkGamer, j);
            }
            else if (Main.netMode == 1 && gamer != null)
            {
                NetMessage.CreateMessage0(11);
                NetMessage.SendMessage();
            }
        }