using System; using System.Collections.Generic; using System.Text; namespace Facepunch.Steamworks { public partial class LobbyList { public class Lobby { private Dictionary lobbyData; internal Client Client; public string Name { get; private set; } public ulong LobbyID { get; private set; } public ulong Owner { get; private set; } public int MemberLimit{ get; private set; } public int NumMembers{ get; private set; } public string LobbyType { get; private set; } /// /// Get the lobby value for the specific key /// /// The key to find /// The value at key public string GetData(string k) { if (lobbyData.TryGetValue(k, out var v)) return v; return string.Empty; } /// /// Get a list of all the data in the Lobby /// /// Dictionary of all the key/value pairs in the data public Dictionary GetAllData() { var returnData = new Dictionary(); foreach ( var item in lobbyData) { returnData.Add(item.Key, item.Value); } return returnData; } internal static Lobby FromSteam(Client client, ulong lobby) { var lobbyData = new Dictionary(); int dataCount = client.native.matchmaking.GetLobbyDataCount(lobby); for (int i = 0; i < dataCount; i++) { if (client.native.matchmaking.GetLobbyDataByIndex(lobby, i, out var datakey, out var datavalue)) { lobbyData.Add(datakey, datavalue); } } return new Lobby() { Client = client, LobbyID = lobby, Name = client.native.matchmaking.GetLobbyData(lobby, "name"), LobbyType = client.native.matchmaking.GetLobbyData(lobby, "lobbytype"), MemberLimit = client.native.matchmaking.GetLobbyMemberLimit(lobby), Owner = client.native.matchmaking.GetLobbyOwner(lobby), NumMembers = client.native.matchmaking.GetNumLobbyMembers(lobby), lobbyData = lobbyData }; } } } }