您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

45 行
1.5 KiB

using System;
using System.Collections.Generic;
using UnityEngine.Serialization;
namespace LobbyRelaySample
{
/// <summary>
/// Used when displaying the lobby list, to indicate when we are awaiting an updated lobby query.
/// </summary>
public enum LobbyQueryState
{
Empty,
Fetching,
Error,
Fetched
}
/// <summary>
/// Holds data related to the Lobby service itself - The latest retrieved lobby list, the state of retrieval.
/// </summary>
[System.Serializable]
public class LocalLobbyList
{
LobbyQueryState m_CurrentState = LobbyQueryState.Empty;
public CallbackValue<LobbyQueryState> QueryState = new CallbackValue<LobbyQueryState>();
public Action<Dictionary<string, LocalLobby>> onLobbyListChange;
Dictionary<string, LocalLobby> m_currentLobbies = new Dictionary<string, LocalLobby>();
/// <summary>
/// Maps from a lobby's ID to the local representation of it. This allows us to remember which remote lobbies are which LocalLobbies.
/// Will only trigger if the dictionary is set wholesale. Changes in the size or contents will not trigger OnChanged.
/// </summary>
public Dictionary<string, LocalLobby> CurrentLobbies
{
get { return m_currentLobbies; }
set
{
m_currentLobbies = value;
onLobbyListChange?.Invoke(m_currentLobbies);
}
}
}
}