Esempio n. 1
0
 public void OnJoinPressed(P2PLobbyInfo data)
 {
     if (ReplTools.IsPlayingAlone() && data != null)
     {
         P2PTransportLayer.OnLobbyListAcquiredEvent -= this.OnLobbyList;
         P2PSession.Instance.JoinLobby(data.m_Address);
         if (this.m_MenuInGameManager)
         {
             this.m_MenuInGameManager.HideMenu();
             return;
         }
         this.OnBack();
     }
 }
Esempio n. 2
0
 public void OnLobbyList(List <P2PLobbyInfo> lobbies)
 {
     if (ReplTools.IsPlayingAlone() && this.m_GamesList != null)
     {
         this.SetListElementCount(lobbies.Count);
         for (int i = 0; i < lobbies.Count; i++)
         {
             Transform child = this.m_GamesList.transform.GetChild(i);
             if (child)
             {
                 P2PLobbyInfo p2PLobbyInfo = lobbies[i];
                 child.GetComponentInChildren <Text>().text = string.Format("{0} [{1}/{2}]", p2PLobbyInfo.m_Name, p2PLobbyInfo.m_MemberCount, p2PLobbyInfo.m_SlotCount);
                 MenuFindGameButtonData component = child.GetComponent <MenuFindGameButtonData>();
                 component.m_LobbyInfo = p2PLobbyInfo;
                 component.m_Parent    = base.gameObject;
             }
         }
     }
     this.UpdateStatusText();
 }
 private void OnLobbyDataUpdate(LobbyDataUpdate_t callback)
 {
     if (callback.m_bSuccess == 1)
     {
         if (this.m_LobbyToJoinId == (CSteamID)callback.m_ulSteamIDLobby)
         {
             if (!SteamMatchmaking.GetLobbyData(this.m_LobbyToJoinId, "game_ver").Equals(GreenHellGame.s_GameVersion.ToString()))
             {
                 if (P2PLogFilter.logWarn)
                 {
                     Debug.LogWarning("[TransportLayerSteam] Connection to lobby aborted - different game versions.");
                 }
                 this.m_LobbyToJoinId = CSteamID.Nil;
                 return;
             }
             CSteamID lobbyToJoinId = this.m_LobbyToJoinId;
             this.Shutdown();
             SteamMatchmaking.JoinLobby(lobbyToJoinId);
             this.m_LobbyToJoinId = CSteamID.Nil;
             this.m_IsInLobby     = true;
             return;
         }
         else
         {
             CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(this.m_LobbyId);
             if (lobbyOwner.m_SteamID != this.m_LobbyOwner.m_SteamID)
             {
                 if (P2PLogFilter.logWarn)
                 {
                     Debug.LogWarning("[TransportLayerSteam] Lobby owner changed");
                 }
                 CSteamID lobbyOwner2 = this.m_LobbyOwner;
                 this.m_LobbyOwner = lobbyOwner;
                 int  numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(this.m_LobbyId);
                 bool flag            = true;
                 for (int i = 0; i < numLobbyMembers; i++)
                 {
                     if (SteamMatchmaking.GetLobbyMemberByIndex(this.m_LobbyId, i).m_SteamID == lobbyOwner2.m_SteamID)
                     {
                         flag = false;
                         break;
                     }
                 }
                 if (flag)
                 {
                     if (P2PLogFilter.logWarn)
                     {
                         Debug.LogWarning("[TransportLayerSteam] Lobby owner left! Disconnecting.");
                     }
                     foreach (KeyValuePair <CSteamID, int> keyValuePair in this.m_Connections)
                     {
                         this.m_ConnectionsBrokenInternal.Push(keyValuePair.Value);
                     }
                     this.Shutdown();
                 }
             }
             else if (this.m_QueriedLobbyList != null)
             {
                 P2PLobbyInfo p2PLobbyInfo = this.m_QueriedLobbyList.FirstOrDefault((P2PLobbyInfo l) => ((P2PAddressSteam)l.m_Address).m_SteamID == (CSteamID)callback.m_ulSteamIDLobby);
                 if (p2PLobbyInfo != null)
                 {
                     CSteamID steamID = ((P2PAddressSteam)p2PLobbyInfo.m_Address).m_SteamID;
                     if (!SteamMatchmaking.GetLobbyData(steamID, "game_ver").Equals(GreenHellGame.s_GameVersion.ToString()))
                     {
                         this.m_QueriedLobbyList.Remove(p2PLobbyInfo);
                     }
                     else
                     {
                         p2PLobbyInfo.m_MemberCount = SteamMatchmaking.GetNumLobbyMembers(steamID);
                         p2PLobbyInfo.m_SlotCount   = SteamMatchmaking.GetLobbyMemberLimit(steamID);
                         p2PLobbyInfo.m_Name        = SteamMatchmaking.GetLobbyData(steamID, "name");
                         p2PLobbyInfo.m_Ready       = true;
                     }
                     bool flag2 = true;
                     using (List <P2PLobbyInfo> .Enumerator enumerator2 = this.m_QueriedLobbyList.GetEnumerator())
                     {
                         while (enumerator2.MoveNext())
                         {
                             if (!enumerator2.Current.m_Ready)
                             {
                                 flag2 = false;
                                 break;
                             }
                         }
                     }
                     if (flag2)
                     {
                         P2PTransportLayer.OnLobbyListAcquired(this.m_QueriedLobbyList);
                         this.m_QueriedLobbyList = null;
                     }
                 }
             }
             if (this.m_LobbyId == (CSteamID)callback.m_ulSteamIDLobby)
             {
                 this.UpdateLobbyMembers();
             }
         }
     }
 }