mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-05-31 15:57:44 +03:00
LobbyQuery Numerical Filters, NearValFilter, SteamClient and Friend OwnsLobby methods
Added LobbyQuery numerical filters for WithLower, WithHigher, WithEqual, and WithNotEqual; added OrderByNear for near value filters. Added OwnsLobby method to SteamClient and Friend to test for ownership.
This commit is contained in:
parent
0300b46ed3
commit
4b8e1e33af
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Steamworks.Data;
|
||||||
|
|
||||||
namespace Steamworks
|
namespace Steamworks
|
||||||
{
|
{
|
||||||
@ -105,7 +106,7 @@ namespace Steamworks
|
|||||||
SteamParties.Shutdown();
|
SteamParties.Shutdown();
|
||||||
SteamNetworkingUtils.Shutdown();
|
SteamNetworkingUtils.Shutdown();
|
||||||
SteamNetworkingSockets.Shutdown();
|
SteamNetworkingSockets.Shutdown();
|
||||||
|
|
||||||
ServerList.Base.Shutdown();
|
ServerList.Base.Shutdown();
|
||||||
|
|
||||||
SteamAPI.Shutdown();
|
SteamAPI.Shutdown();
|
||||||
@ -169,6 +170,11 @@ namespace Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static AppId AppId { get; internal set; }
|
public static AppId AppId { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if this SteamClient owns the specified lobby
|
||||||
|
/// </summary>
|
||||||
|
public static bool OwnsLobby( Lobby k ) => k.Owner.Id == SteamId;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if your executable was launched through Steam and relaunches it through Steam if it wasn't
|
/// Checks if your executable was launched through Steam and relaunches it through Steam if it wasn't
|
||||||
/// this returns true then it starts the Steam client if required and launches your game again through it,
|
/// this returns true then it starts the Steam client if required and launches your game again through it,
|
||||||
|
@ -71,6 +71,11 @@ namespace Steamworks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsSnoozing => State == FriendState.Snooze;
|
public bool IsSnoozing => State == FriendState.Snooze;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if this Friend owns the specified lobby
|
||||||
|
/// </summary>
|
||||||
|
public bool OwnsLobby( Lobby k ) => k.Owner.Id == this.Id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Relationship Relationship => SteamFriends.Internal.GetFriendRelationship( Id );
|
public Relationship Relationship => SteamFriends.Internal.GetFriendRelationship( Id );
|
||||||
|
@ -7,11 +7,7 @@ namespace Steamworks.Data
|
|||||||
{
|
{
|
||||||
// TODO FILTERS
|
// TODO FILTERS
|
||||||
// AddRequestLobbyListStringFilter
|
// AddRequestLobbyListStringFilter
|
||||||
// - WithKeyValue, WithoutKeyValue
|
// - WithoutKeyValue
|
||||||
// AddRequestLobbyListNumericalFilter
|
|
||||||
// - WithLower, WithHigher, WithEqual, WithNotEqual
|
|
||||||
// AddRequestLobbyListNearValueFilter
|
|
||||||
// - OrderByNear
|
|
||||||
|
|
||||||
#region Distance Filter
|
#region Distance Filter
|
||||||
internal LobbyDistanceFilter? distance;
|
internal LobbyDistanceFilter? distance;
|
||||||
@ -67,6 +63,89 @@ namespace Steamworks.Data
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Numerical filters
|
||||||
|
internal Dictionary<KeyValuePair<string, int>, LobbyComparison> numericalFilters;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Numerical filter where value is less than the value provided
|
||||||
|
/// </summary>
|
||||||
|
public LobbyQuery WithLower( string key, int value )
|
||||||
|
{
|
||||||
|
AddNumericalFilter( key, value, LobbyComparison.LessThan );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Numerical filter where value is greater than the value provided
|
||||||
|
/// </summary>
|
||||||
|
public LobbyQuery WithHigher( string key, int value )
|
||||||
|
{
|
||||||
|
AddNumericalFilter( key, value, LobbyComparison.GreaterThan );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Numerical filter where value must be equal to the value provided
|
||||||
|
/// </summary>
|
||||||
|
public LobbyQuery WithEqual( string key, int value )
|
||||||
|
{
|
||||||
|
AddNumericalFilter( key, value, LobbyComparison.Equal );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Numerical filter where value must not equal the value provided
|
||||||
|
/// </summary>
|
||||||
|
public LobbyQuery WithNotEqual( string key, int value )
|
||||||
|
{
|
||||||
|
AddNumericalFilter( key, value, LobbyComparison.NotEqual );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test key, initialize numerical filter dictionary if necessary, then add new numerical filter
|
||||||
|
/// </summary>
|
||||||
|
internal LobbyQuery AddNumericalFilter( string key, int value, LobbyComparison compare )
|
||||||
|
{
|
||||||
|
if ( string.IsNullOrEmpty( key ) )
|
||||||
|
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( key ) );
|
||||||
|
|
||||||
|
if ( key.Length > SteamMatchmaking.MaxLobbyKeyLength )
|
||||||
|
throw new System.ArgumentException( $"Key length is longer than {SteamMatchmaking.MaxLobbyKeyLength}", nameof( key ) );
|
||||||
|
|
||||||
|
if ( numericalFilters == null )
|
||||||
|
numericalFilters = new Dictionary<KeyValuePair<string, int>, LobbyComparison>();
|
||||||
|
|
||||||
|
numericalFilters.Add( new KeyValuePair<string, int>( key, value ), compare );
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Near value filter
|
||||||
|
internal Dictionary<string, int> nearValFilters;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Order filtered results according to key/values nearest the provided key/value pair.
|
||||||
|
/// Can specify multiple near value filters; each successive filter is lower priority than the previous.
|
||||||
|
/// </summary>
|
||||||
|
public LobbyQuery OrderByNear( string key, int value )
|
||||||
|
{
|
||||||
|
if ( string.IsNullOrEmpty( key ) )
|
||||||
|
throw new System.ArgumentException( "Key string provided for LobbyQuery filter is null or empty", nameof( key ) );
|
||||||
|
|
||||||
|
if ( key.Length > SteamMatchmaking.MaxLobbyKeyLength )
|
||||||
|
throw new System.ArgumentException( $"Key length is longer than {SteamMatchmaking.MaxLobbyKeyLength}", nameof( key ) );
|
||||||
|
|
||||||
|
if ( nearValFilters == null )
|
||||||
|
nearValFilters = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
nearValFilters.Add( key, value );
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Slots Filter
|
#region Slots Filter
|
||||||
internal int? slotsAvailable;
|
internal int? slotsAvailable;
|
||||||
|
|
||||||
@ -95,7 +174,6 @@ namespace Steamworks.Data
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
void ApplyFilters()
|
void ApplyFilters()
|
||||||
{
|
{
|
||||||
if ( distance.HasValue )
|
if ( distance.HasValue )
|
||||||
@ -120,6 +198,22 @@ namespace Steamworks.Data
|
|||||||
SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( k.Key, k.Value, LobbyComparison.Equal );
|
SteamMatchmaking.Internal.AddRequestLobbyListStringFilter( k.Key, k.Value, LobbyComparison.Equal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( numericalFilters != null )
|
||||||
|
{
|
||||||
|
foreach ( var n in numericalFilters )
|
||||||
|
{
|
||||||
|
SteamMatchmaking.Internal.AddRequestLobbyListNumericalFilter( n.Key.Key, n.Key.Value, n.Value );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( nearValFilters != null )
|
||||||
|
{
|
||||||
|
foreach (var v in nearValFilters )
|
||||||
|
{
|
||||||
|
SteamMatchmaking.Internal.AddRequestLobbyListNearValueFilter( v.Key, v.Value );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user