mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 07:05:50 +03:00
Merge pull request #277 from thesupersoup/master
LobbyQuery FilterStringKeyValue method
This commit is contained in:
commit
57f3b334b5
@ -12,6 +12,12 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public static class SteamMatchmaking
|
||||
{
|
||||
/// <summary>
|
||||
/// Maximum number of characters a lobby metadata key can be
|
||||
/// </summary>
|
||||
internal static int MaxLobbyKeyLength => 255;
|
||||
|
||||
|
||||
static ISteamMatchmaking _internal;
|
||||
|
||||
internal static ISteamMatchmaking Internal
|
||||
@ -37,7 +43,7 @@ internal static void InstallEvents()
|
||||
{
|
||||
LobbyInvite_t.Install( x => OnLobbyInvite?.Invoke( new Friend( x.SteamIDUser ), new Lobby( x.SteamIDLobby ) ) );
|
||||
|
||||
LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby(x.SteamIDLobby ) ) );
|
||||
LobbyEnter_t.Install( x => OnLobbyEntered?.Invoke( new Lobby( x.SteamIDLobby ) ) );
|
||||
|
||||
LobbyDataUpdate_t.Install( x =>
|
||||
{
|
||||
|
@ -43,6 +43,30 @@ public LobbyQuery FilterDistanceWorldwide()
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region String key/value filter
|
||||
internal MatchMakingKeyValuePair_t? stringFilter;
|
||||
|
||||
/// <summary>
|
||||
/// Filter by specified key/value pair; string parameters
|
||||
/// </summary>
|
||||
public LobbyQuery FilterStringKeyValue( string nKey, string nValue )
|
||||
{
|
||||
if ( string.IsNullOrEmpty( nKey ) )
|
||||
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( nKey ) );
|
||||
|
||||
if ( nKey.Length > SteamMatchmaking.MaxLobbyKeyLength )
|
||||
throw new System.ArgumentException( "Key length is longer than MaxLobbyKeyLength", nameof( nKey ) );
|
||||
|
||||
stringFilter = new MatchMakingKeyValuePair_t
|
||||
{
|
||||
Key = nKey,
|
||||
Value = nValue
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Slots Filter
|
||||
internal int? slotsAvailable;
|
||||
|
||||
@ -88,6 +112,11 @@ void ApplyFilters()
|
||||
{
|
||||
SteamMatchmaking.Internal.AddRequestLobbyListResultCountFilter( maxResults.Value );
|
||||
}
|
||||
|
||||
if( stringFilter.HasValue )
|
||||
{
|
||||
SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( stringFilter.Value.Key, stringFilter.Value.Value, LobbyComparison.Equal );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user