v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -25,16 +25,16 @@ namespace Steamworks.Data
|
||||
get
|
||||
{
|
||||
var state = false;
|
||||
SteamUserStats.Internal.GetAchievement( Value, ref state );
|
||||
SteamUserStats.Internal?.GetAchievement( Value, ref state );
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
public string Identifier => Value;
|
||||
|
||||
public string Name => SteamUserStats.Internal.GetAchievementDisplayAttribute( Value, "name" );
|
||||
public string? Name => SteamUserStats.Internal?.GetAchievementDisplayAttribute( Value, "name" );
|
||||
|
||||
public string Description => SteamUserStats.Internal.GetAchievementDisplayAttribute( Value, "desc" );
|
||||
public string? Description => SteamUserStats.Internal?.GetAchievementDisplayAttribute( Value, "desc" );
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -47,7 +47,7 @@ namespace Steamworks.Data
|
||||
var state = false;
|
||||
uint time = 0;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetAchievementAndUnlockTime( Value, ref state, ref time ) || !state )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetAchievementAndUnlockTime( Value, ref state, ref time ) || !state )
|
||||
return null;
|
||||
|
||||
return Epoch.ToDateTime( time );
|
||||
@@ -60,6 +60,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public Image? GetIcon()
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
return SteamUtils.GetImage( SteamUserStats.Internal.GetAchievementIcon( Value ) );
|
||||
}
|
||||
|
||||
@@ -69,6 +70,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public async Task<Image?> GetIconAsync( int timeout = 5000 )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
var i = SteamUserStats.Internal.GetAchievementIcon( Value );
|
||||
if ( i != 0 ) return SteamUtils.GetImage( i );
|
||||
|
||||
@@ -115,7 +117,7 @@ namespace Steamworks.Data
|
||||
{
|
||||
float pct = 0;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetAchievementAchievedPercent( Value, ref pct ) )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetAchievementAchievedPercent( Value, ref pct ) )
|
||||
return -1.0f;
|
||||
|
||||
return pct / 100.0f;
|
||||
@@ -127,6 +129,8 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool Trigger( bool apply = true )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return false; }
|
||||
|
||||
var r = SteamUserStats.Internal.SetAchievement( Value );
|
||||
|
||||
if ( apply && r )
|
||||
@@ -142,6 +146,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool Clear()
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return false; }
|
||||
return SteamUserStats.Internal.ClearAchievement( Value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,20 @@ namespace Steamworks
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public string Name => SteamFriends.Internal.GetClanName(Id);
|
||||
public string? Name => SteamFriends.Internal?.GetClanName(Id);
|
||||
|
||||
public string Tag => SteamFriends.Internal.GetClanTag(Id);
|
||||
public string? Tag => SteamFriends.Internal?.GetClanTag(Id);
|
||||
|
||||
public int ChatMemberCount => SteamFriends.Internal.GetClanChatMemberCount(Id);
|
||||
public int ChatMemberCount => SteamFriends.Internal?.GetClanChatMemberCount(Id) ?? 0;
|
||||
|
||||
public Friend Owner => new Friend(SteamFriends.Internal.GetClanOwner(Id));
|
||||
public Friend Owner => new Friend(SteamFriends.Internal?.GetClanOwner(Id) ?? 0);
|
||||
|
||||
public bool Public => SteamFriends.Internal.IsClanPublic(Id);
|
||||
public bool Public => SteamFriends.Internal != null && SteamFriends.Internal.IsClanPublic(Id);
|
||||
|
||||
/// <summary>
|
||||
/// Is the clan an official game group?
|
||||
/// </summary>
|
||||
public bool Official => SteamFriends.Internal.IsClanOfficialGameGroup(Id);
|
||||
public bool Official => SteamFriends.Internal != null && SteamFriends.Internal.IsClanOfficialGameGroup(Id);
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously fetches the officer list for a given clan
|
||||
@@ -35,14 +35,18 @@ namespace Steamworks
|
||||
/// <returns>Whether the request was successful or not</returns>
|
||||
public async Task<bool> RequestOfficerList()
|
||||
{
|
||||
if (SteamFriends.Internal is null) { return false; }
|
||||
var req = await SteamFriends.Internal.RequestClanOfficerList(Id);
|
||||
return req.HasValue && req.Value.Success != 0x0;
|
||||
}
|
||||
|
||||
public IEnumerable<Friend> GetOfficers()
|
||||
{
|
||||
for (int i = 0; i < SteamFriends.Internal.GetClanOfficerCount(Id); i++)
|
||||
if (SteamFriends.Internal is null) { yield break; }
|
||||
var officerCount = SteamFriends.Internal.GetClanOfficerCount(Id);
|
||||
for (int i = 0; i < officerCount; i++)
|
||||
{
|
||||
if (SteamFriends.Internal is null) { yield break; }
|
||||
yield return new Friend(SteamFriends.Internal.GetClanOfficerByIndex(Id, i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Steamworks
|
||||
}
|
||||
|
||||
public ulong Id => Handle.Value;
|
||||
public InputType InputType => SteamInput.Internal.GetInputTypeForHandle( Handle );
|
||||
public InputType InputType => SteamInput.Internal?.GetInputTypeForHandle( Handle ) ?? InputType.Unknown;
|
||||
|
||||
/// <summary>
|
||||
/// Reconfigure the controller to use the specified action set (ie 'Menu', 'Walk' or 'Drive')
|
||||
@@ -23,12 +23,12 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public string ActionSet
|
||||
{
|
||||
set => SteamInput.Internal.ActivateActionSet( Handle, SteamInput.Internal.GetActionSetHandle( value ) );
|
||||
set => SteamInput.Internal?.ActivateActionSet( Handle, SteamInput.Internal.GetActionSetHandle( value ) );
|
||||
}
|
||||
|
||||
public void DeactivateLayer( string layer ) => SteamInput.Internal.DeactivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||
public void ActivateLayer( string layer ) => SteamInput.Internal.ActivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||
public void ClearLayers() => SteamInput.Internal.DeactivateAllActionSetLayers( Handle );
|
||||
public void DeactivateLayer( string layer ) => SteamInput.Internal?.DeactivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||
public void ActivateLayer( string layer ) => SteamInput.Internal?.ActivateActionSetLayer( Handle, SteamInput.Internal.GetActionSetHandle( layer ) );
|
||||
public void ClearLayers() => SteamInput.Internal?.DeactivateAllActionSetLayers( Handle );
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +36,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public DigitalState GetDigitalState( string actionName )
|
||||
{
|
||||
return SteamInput.Internal.GetDigitalActionData( Handle, SteamInput.GetDigitalActionHandle( actionName ) );
|
||||
return SteamInput.Internal?.GetDigitalActionData( Handle, SteamInput.GetDigitalActionHandle( actionName ) ) ?? default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -44,7 +44,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public AnalogState GetAnalogState( string actionName )
|
||||
{
|
||||
return SteamInput.Internal.GetAnalogActionData( Handle, SteamInput.GetAnalogActionHandle( actionName ) );
|
||||
return SteamInput.Internal?.GetAnalogActionData( Handle, SteamInput.GetAnalogActionHandle( actionName ) ) ?? default;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -73,16 +73,16 @@ namespace Steamworks
|
||||
|
||||
|
||||
|
||||
public Relationship Relationship => SteamFriends.Internal.GetFriendRelationship( Id );
|
||||
public FriendState State => SteamFriends.Internal.GetFriendPersonaState( Id );
|
||||
public string Name => SteamFriends.Internal.GetFriendPersonaName( Id );
|
||||
public Relationship Relationship => SteamFriends.Internal?.GetFriendRelationship( Id ) ?? Relationship.None;
|
||||
public FriendState State => SteamFriends.Internal?.GetFriendPersonaState( Id ) ?? FriendState.Offline;
|
||||
public string? Name => SteamFriends.Internal?.GetFriendPersonaName( Id );
|
||||
public IEnumerable<string> NameHistory
|
||||
{
|
||||
get
|
||||
{
|
||||
for( int i=0; i<32; i++ )
|
||||
{
|
||||
var n = SteamFriends.Internal.GetFriendPersonaNameHistory( Id, i );
|
||||
var n = SteamFriends.Internal?.GetFriendPersonaNameHistory( Id, i );
|
||||
if ( string.IsNullOrEmpty( n ) )
|
||||
break;
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Steamworks
|
||||
}
|
||||
}
|
||||
|
||||
public int SteamLevel => SteamFriends.Internal.GetFriendSteamLevel( Id );
|
||||
public int SteamLevel => SteamFriends.Internal?.GetFriendSteamLevel( Id ) ?? 0;
|
||||
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Steamworks
|
||||
get
|
||||
{
|
||||
FriendGameInfo_t gameInfo = default;
|
||||
if ( !SteamFriends.Internal.GetFriendGamePlayed( Id, ref gameInfo ) )
|
||||
if ( SteamFriends.Internal is null || !SteamFriends.Internal.GetFriendGamePlayed( Id, ref gameInfo ) )
|
||||
return null;
|
||||
|
||||
return FriendGameInfo.From( gameInfo );
|
||||
@@ -109,7 +109,7 @@ namespace Steamworks
|
||||
|
||||
public bool IsIn( SteamId group_or_room )
|
||||
{
|
||||
return SteamFriends.Internal.IsUserInSource( Id, group_or_room );
|
||||
return SteamFriends.Internal != null && SteamFriends.Internal.IsUserInSource( Id, group_or_room );
|
||||
}
|
||||
|
||||
public struct FriendGameInfo
|
||||
@@ -161,9 +161,9 @@ namespace Steamworks
|
||||
return await SteamFriends.GetLargeAvatarAsync( Id );
|
||||
}
|
||||
|
||||
public string GetRichPresence( string key )
|
||||
public string? GetRichPresence( string key )
|
||||
{
|
||||
var val = SteamFriends.Internal.GetFriendRichPresence( Id, key );
|
||||
var val = SteamFriends.Internal?.GetFriendRichPresence( Id, key );
|
||||
if ( string.IsNullOrEmpty( val ) ) return null;
|
||||
return val;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public bool InviteToGame( string Text )
|
||||
{
|
||||
return SteamFriends.Internal.InviteUserToGame( Id, Text );
|
||||
return SteamFriends.Internal != null && SteamFriends.Internal.InviteUserToGame( Id, Text );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -181,7 +181,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public bool SendMessage( string message )
|
||||
{
|
||||
return SteamFriends.Internal.ReplyToFriendMessage( Id, message );
|
||||
return SteamFriends.Internal != null && SteamFriends.Internal.ReplyToFriendMessage( Id, message );
|
||||
}
|
||||
|
||||
|
||||
@@ -191,8 +191,9 @@ namespace Steamworks
|
||||
/// <returns>True if successful, False if failure</returns>
|
||||
public async Task<bool> RequestUserStatsAsync()
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return false; }
|
||||
var result = await SteamUserStats.Internal.RequestUserStats( Id );
|
||||
return result.HasValue && result.Value.Result == Result.OK;
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -205,7 +206,7 @@ namespace Steamworks
|
||||
{
|
||||
var val = defult;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetUserStat( Id, statName, ref val ) )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetUserStat( Id, statName, ref val ) )
|
||||
return defult;
|
||||
|
||||
return val;
|
||||
@@ -221,7 +222,7 @@ namespace Steamworks
|
||||
{
|
||||
var val = defult;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetUserStat( Id, statName, ref val ) )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetUserStat( Id, statName, ref val ) )
|
||||
return defult;
|
||||
|
||||
return val;
|
||||
@@ -237,7 +238,7 @@ namespace Steamworks
|
||||
{
|
||||
var val = defult;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetUserAchievement( Id, statName, ref val ) )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetUserAchievement( Id, statName, ref val ) )
|
||||
return defult;
|
||||
|
||||
return val;
|
||||
@@ -253,7 +254,7 @@ namespace Steamworks
|
||||
bool val = false;
|
||||
uint time = 0;
|
||||
|
||||
if ( !SteamUserStats.Internal.GetUserAchievementAndUnlockTime( Id, statName, ref val, ref time ) || !val )
|
||||
if ( SteamUserStats.Internal is null || !SteamUserStats.Internal.GetUserAchievementAndUnlockTime( Id, statName, ref val, ref time ) || !val )
|
||||
return DateTime.MinValue;
|
||||
|
||||
return Epoch.ToDateTime( time );
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Steamworks
|
||||
public class InventoryDef : IEquatable<InventoryDef>
|
||||
{
|
||||
internal InventoryDefId _id;
|
||||
internal Dictionary<string, string> _properties;
|
||||
internal Dictionary<string, string>? _properties;
|
||||
|
||||
public InventoryDef( InventoryDefId defId )
|
||||
{
|
||||
@@ -20,32 +20,32 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "name" )
|
||||
/// </summary>
|
||||
public string Name => GetProperty( "name" );
|
||||
public string? Name => GetProperty( "name" );
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "description" )
|
||||
/// </summary>
|
||||
public string Description => GetProperty( "description" );
|
||||
public string? Description => GetProperty( "description" );
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "icon_url" )
|
||||
/// </summary>
|
||||
public string IconUrl => GetProperty( "icon_url" );
|
||||
public string? IconUrl => GetProperty( "icon_url" );
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "icon_url_large" )
|
||||
/// </summary>
|
||||
public string IconUrlLarge => GetProperty( "icon_url_large" );
|
||||
public string? IconUrlLarge => GetProperty( "icon_url_large" );
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "price_category" )
|
||||
/// </summary>
|
||||
public string PriceCategory => GetProperty( "price_category" );
|
||||
public string? PriceCategory => GetProperty( "price_category" );
|
||||
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "type" )
|
||||
/// </summary>
|
||||
public string Type => GetProperty( "type" );
|
||||
public string? Type => GetProperty( "type" );
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this is an item that generates an item, rather
|
||||
@@ -56,12 +56,12 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Shortcut to call GetProperty( "exchange" )
|
||||
/// </summary>
|
||||
public string ExchangeSchema => GetProperty( "exchange" );
|
||||
public string? ExchangeSchema => GetProperty( "exchange" );
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of exchanges that are available to make this item
|
||||
/// </summary>
|
||||
public InventoryRecipe[] GetRecipes()
|
||||
public InventoryRecipe[]? GetRecipes()
|
||||
{
|
||||
if ( string.IsNullOrEmpty( ExchangeSchema ) ) return null;
|
||||
|
||||
@@ -93,19 +93,19 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Get a specific property by name
|
||||
/// </summary>
|
||||
public string GetProperty( string name )
|
||||
public string? GetProperty( string? name )
|
||||
{
|
||||
if ( _properties!= null && _properties.TryGetValue( name, out string val ) )
|
||||
if ( _properties != null && name != null && _properties.TryGetValue( name, out string val ) )
|
||||
return val;
|
||||
|
||||
uint _ = (uint)Helpers.MemoryBufferSize;
|
||||
|
||||
if ( !SteamInventory.Internal.GetItemDefinitionProperty( Id, name, out var vl, ref _ ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetItemDefinitionProperty( Id, name, out var vl, ref _ ) )
|
||||
return null;
|
||||
|
||||
|
||||
if (name == null) //return keys string
|
||||
return vl;
|
||||
|
||||
|
||||
if ( _properties == null )
|
||||
_properties = new Dictionary<string, string>();
|
||||
|
||||
@@ -119,9 +119,9 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public bool GetBoolProperty( string name )
|
||||
{
|
||||
string val = GetProperty( name );
|
||||
string? val = GetProperty( name );
|
||||
|
||||
if ( val.Length == 0 ) return false;
|
||||
if ( string.IsNullOrEmpty(val) ) return false;
|
||||
if ( val[0] == '0' || val[0] == 'F' || val[0] == 'f' ) return false;
|
||||
|
||||
return true;
|
||||
@@ -130,9 +130,9 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Read a raw property from the definition schema
|
||||
/// </summary>
|
||||
public T GetProperty<T>( string name )
|
||||
public T? GetProperty<T>( string name )
|
||||
{
|
||||
string val = GetProperty( name );
|
||||
string? val = GetProperty( name );
|
||||
|
||||
if ( string.IsNullOrEmpty( val ) )
|
||||
return default;
|
||||
@@ -150,16 +150,16 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Gets a list of all properties on this item
|
||||
/// </summary>
|
||||
public IEnumerable<KeyValuePair<string, string>> Properties
|
||||
public IEnumerable<KeyValuePair<string, string?>> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = GetProperty( null );
|
||||
var list = GetProperty( null ) ?? "";
|
||||
var keys = list.Split( ',' );
|
||||
|
||||
foreach ( var key in keys )
|
||||
{
|
||||
yield return new KeyValuePair<string, string>( key, GetProperty( key ) );
|
||||
yield return new KeyValuePair<string, string?>( key, GetProperty( key ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace Steamworks
|
||||
ulong curprice = 0;
|
||||
ulong baseprice = 0;
|
||||
|
||||
if ( !SteamInventory.Internal.GetItemPrice( Id, ref curprice, ref baseprice ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetItemPrice( Id, ref curprice, ref baseprice ) )
|
||||
return 0;
|
||||
|
||||
return (int) curprice;
|
||||
@@ -194,7 +194,7 @@ namespace Steamworks
|
||||
ulong curprice = 0;
|
||||
ulong baseprice = 0;
|
||||
|
||||
if ( !SteamInventory.Internal.GetItemPrice( Id, ref curprice, ref baseprice ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetItemPrice( Id, ref curprice, ref baseprice ) )
|
||||
return 0;
|
||||
|
||||
return (int)baseprice;
|
||||
@@ -203,12 +203,12 @@ namespace Steamworks
|
||||
|
||||
public string LocalBasePriceFormatted => Utility.FormatPrice( SteamInventory.Currency, LocalPrice / 100.0 );
|
||||
|
||||
InventoryRecipe[] _recContaining;
|
||||
InventoryRecipe[]? _recContaining;
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of recepies that contain this item
|
||||
/// </summary>
|
||||
public InventoryRecipe[] GetRecipesContainingThis()
|
||||
public InventoryRecipe[]? GetRecipesContainingThis()
|
||||
{
|
||||
if ( _recContaining != null ) return _recContaining;
|
||||
|
||||
@@ -221,17 +221,17 @@ namespace Steamworks
|
||||
return _recContaining;
|
||||
}
|
||||
|
||||
public static bool operator ==( InventoryDef a, InventoryDef b )
|
||||
public static bool operator ==( InventoryDef? a, InventoryDef? b )
|
||||
{
|
||||
if ( Object.ReferenceEquals( a, null ) )
|
||||
return Object.ReferenceEquals( b, null );
|
||||
|
||||
return a.Equals( b );
|
||||
}
|
||||
public static bool operator !=( InventoryDef a, InventoryDef b ) => !(a == b);
|
||||
public static bool operator !=( InventoryDef? a, InventoryDef? b ) => !(a == b);
|
||||
public override bool Equals( object p ) => this.Equals( (InventoryDef)p );
|
||||
public override int GetHashCode() => Id.GetHashCode();
|
||||
public bool Equals( InventoryDef p )
|
||||
public bool Equals( InventoryDef? p )
|
||||
{
|
||||
if ( p == null ) return false;
|
||||
return p.Id == Id;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Steamworks
|
||||
internal InventoryDefId _def;
|
||||
internal SteamItemFlags _flags;
|
||||
internal ushort _quantity;
|
||||
internal Dictionary<string, string> _properties;
|
||||
internal Dictionary<string, string>? _properties;
|
||||
|
||||
public InventoryItemId Id => _id;
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace Steamworks
|
||||
|
||||
public int Quantity => _quantity;
|
||||
|
||||
public InventoryDef Def => SteamInventory.FindDefinition( DefId );
|
||||
public InventoryDef? Def => SteamInventory.FindDefinition( DefId );
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Only available if the result set was created with the getproperties
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Properties => _properties;
|
||||
public Dictionary<string, string>? Properties => _properties;
|
||||
|
||||
/// <summary>
|
||||
/// This item is account-locked and cannot be traded or given away.
|
||||
@@ -54,7 +54,7 @@ namespace Steamworks
|
||||
public async Task<InventoryResult?> ConsumeAsync( int amount = 1 )
|
||||
{
|
||||
var sresult = Defines.k_SteamInventoryResultInvalid;
|
||||
if ( !SteamInventory.Internal.ConsumeItem( ref sresult, Id, (uint)amount ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.ConsumeItem( ref sresult, Id, (uint)amount ) )
|
||||
return null;
|
||||
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
@@ -66,7 +66,7 @@ namespace Steamworks
|
||||
public async Task<InventoryResult?> SplitStackAsync( int quantity = 1 )
|
||||
{
|
||||
var sresult = Defines.k_SteamInventoryResultInvalid;
|
||||
if ( !SteamInventory.Internal.TransferItemQuantity( ref sresult, Id, (uint)quantity, ulong.MaxValue ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.TransferItemQuantity( ref sresult, Id, (uint)quantity, ulong.MaxValue ) )
|
||||
return null;
|
||||
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
@@ -78,7 +78,7 @@ namespace Steamworks
|
||||
public async Task<InventoryResult?> AddAsync( InventoryItem add, int quantity = 1 )
|
||||
{
|
||||
var sresult = Defines.k_SteamInventoryResultInvalid;
|
||||
if ( !SteamInventory.Internal.TransferItemQuantity( ref sresult, add.Id, (uint)quantity, Id ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.TransferItemQuantity( ref sresult, add.Id, (uint)quantity, Id ) )
|
||||
return null;
|
||||
|
||||
return await InventoryResult.GetAsync( sresult );
|
||||
@@ -98,11 +98,11 @@ namespace Steamworks
|
||||
return i;
|
||||
}
|
||||
|
||||
internal static Dictionary<string, string> GetProperties( SteamInventoryResult_t result, int index )
|
||||
internal static Dictionary<string, string>? GetProperties( SteamInventoryResult_t result, int index )
|
||||
{
|
||||
var strlen = (uint) Helpers.MemoryBufferSize;
|
||||
|
||||
if ( !SteamInventory.Internal.GetResultItemProperty( result, (uint)index, null, out var propNames, ref strlen ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetResultItemProperty( result, (uint)index, null, out var propNames, ref strlen ) )
|
||||
return null;
|
||||
|
||||
var props = new Dictionary<string, string>();
|
||||
@@ -151,7 +151,7 @@ namespace Steamworks
|
||||
/// Tries to get the origin property. Need properties for this to work.
|
||||
/// Will return a string like "market"
|
||||
/// </summary>
|
||||
public string Origin
|
||||
public string? Origin
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Steamworks
|
||||
/// If we don't know about this item definition this might be null.
|
||||
/// In which case, DefinitionId should still hold the correct id.
|
||||
/// </summary>
|
||||
public InventoryDef Definition;
|
||||
public InventoryDef? Definition;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of this item needed. Generally this will be 1.
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Steamworks
|
||||
{
|
||||
uint cnt = 0;
|
||||
|
||||
if ( !SteamInventory.Internal.GetResultItems( _id, null, ref cnt ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetResultItems( _id, null, ref cnt ) )
|
||||
return 0;
|
||||
|
||||
return (int) cnt;
|
||||
@@ -36,17 +36,17 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public bool BelongsTo( SteamId steamId )
|
||||
{
|
||||
return SteamInventory.Internal.CheckResultSteamID( _id, steamId );
|
||||
return SteamInventory.Internal != null && SteamInventory.Internal.CheckResultSteamID( _id, steamId );
|
||||
}
|
||||
|
||||
public InventoryItem[] GetItems( bool includeProperties = false )
|
||||
public InventoryItem[]? GetItems( bool includeProperties = false )
|
||||
{
|
||||
uint cnt = (uint) ItemCount;
|
||||
if ( cnt <= 0 ) return null;
|
||||
|
||||
var pOutItemsArray = new SteamItemDetails_t[cnt];
|
||||
|
||||
if ( !SteamInventory.Internal.GetResultItems( _id, pOutItemsArray, ref cnt ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.GetResultItems( _id, pOutItemsArray, ref cnt ) )
|
||||
return null;
|
||||
|
||||
var items = new InventoryItem[cnt];
|
||||
@@ -69,7 +69,7 @@ namespace Steamworks
|
||||
{
|
||||
if ( _id.Value == -1 ) return;
|
||||
|
||||
SteamInventory.Internal.DestroyResult( _id );
|
||||
SteamInventory.Internal?.DestroyResult( _id );
|
||||
}
|
||||
|
||||
internal static async Task<InventoryResult?> GetAsync( SteamInventoryResult_t sresult )
|
||||
@@ -77,7 +77,7 @@ namespace Steamworks
|
||||
var _result = Result.Pending;
|
||||
while ( _result == Result.Pending )
|
||||
{
|
||||
_result = SteamInventory.Internal.GetResultStatus( sresult );
|
||||
_result = SteamInventory.Internal?.GetResultStatus( sresult ) ?? Result.Fail;
|
||||
await Task.Delay( 10 );
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ namespace Steamworks
|
||||
/// Results have a built-in timestamp which will be considered "expired" after an hour has elapsed.See DeserializeResult
|
||||
/// for expiration handling.
|
||||
/// </summary>
|
||||
public unsafe byte[] Serialize()
|
||||
public unsafe byte[]? Serialize()
|
||||
{
|
||||
uint size = 0;
|
||||
|
||||
if ( !SteamInventory.Internal.SerializeResult( _id, IntPtr.Zero, ref size ) )
|
||||
if ( SteamInventory.Internal is null || !SteamInventory.Internal.SerializeResult( _id, IntPtr.Zero, ref size ) )
|
||||
return null;
|
||||
|
||||
var data = new byte[size];
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// the name of a leaderboard
|
||||
/// </summary>
|
||||
public string Name => SteamUserStats.Internal.GetLeaderboardName( Id );
|
||||
public LeaderboardSort Sort => SteamUserStats.Internal.GetLeaderboardSortMethod( Id );
|
||||
public LeaderboardDisplay Display => SteamUserStats.Internal.GetLeaderboardDisplayType( Id );
|
||||
public int EntryCount => SteamUserStats.Internal.GetLeaderboardEntryCount(Id);
|
||||
public string? Name => SteamUserStats.Internal?.GetLeaderboardName( Id );
|
||||
public LeaderboardSort Sort => SteamUserStats.Internal?.GetLeaderboardSortMethod( Id ) ?? default;
|
||||
public LeaderboardDisplay Display => SteamUserStats.Internal?.GetLeaderboardDisplayType( Id ) ?? default;
|
||||
public int EntryCount => SteamUserStats.Internal?.GetLeaderboardEntryCount(Id) ?? 0;
|
||||
|
||||
static int[] detailsBuffer = new int[64];
|
||||
static int[] noDetails = Array.Empty<int>();
|
||||
@@ -25,8 +25,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Submit your score and replace your old score even if it was better
|
||||
/// </summary>
|
||||
public async Task<LeaderboardUpdate?> ReplaceScore( int score, int[] details = null )
|
||||
public async Task<LeaderboardUpdate?> ReplaceScore( int score, int[]? details = null )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
if ( details == null ) details = noDetails;
|
||||
|
||||
var r = await SteamUserStats.Internal.UploadLeaderboardScore( Id, LeaderboardUploadScoreMethod.ForceUpdate, score, details, details.Length );
|
||||
@@ -38,8 +39,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Submit your new score, but won't replace your high score if it's lower
|
||||
/// </summary>
|
||||
public async Task<LeaderboardUpdate?> SubmitScoreAsync( int score, int[] details = null )
|
||||
public async Task<LeaderboardUpdate?> SubmitScoreAsync( int score, int[]? details = null )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
if ( details == null ) details = noDetails;
|
||||
|
||||
var r = await SteamUserStats.Internal.UploadLeaderboardScore( Id, LeaderboardUploadScoreMethod.KeepBest, score, details, details.Length );
|
||||
@@ -53,6 +55,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public async Task<Result> AttachUgc( Ugc file )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return Result.Fail; }
|
||||
var r = await SteamUserStats.Internal.AttachLeaderboardUGC( Id, file.Handle );
|
||||
if ( !r.HasValue ) return Result.Fail;
|
||||
|
||||
@@ -62,8 +65,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Fetches leaderboard entries for an arbitrary set of users on a specified leaderboard.
|
||||
/// </summary>
|
||||
public async Task<LeaderboardEntry[]> GetScoresForUsersAsync( SteamId[] users )
|
||||
public async Task<LeaderboardEntry[]?> GetScoresForUsersAsync( SteamId[]? users )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
if ( users == null || users.Length == 0 )
|
||||
return null;
|
||||
|
||||
@@ -77,8 +81,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Used to query for a sequential range of leaderboard entries by leaderboard Sort.
|
||||
/// </summary>
|
||||
public async Task<LeaderboardEntry[]> GetScoresAsync( int count, int offset = 1 )
|
||||
public async Task<LeaderboardEntry[]?> GetScoresAsync( int count, int offset = 1 )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
if ( offset <= 0 ) throw new System.ArgumentException( "Should be 1+", nameof( offset ) );
|
||||
|
||||
var r = await SteamUserStats.Internal.DownloadLeaderboardEntries( Id, LeaderboardDataRequest.Global, offset, offset + count - 1 );
|
||||
@@ -94,8 +99,9 @@ namespace Steamworks.Data
|
||||
/// For example, if the user is #1 on the leaderboard and start is set to -2, end is set to 2, Steam will return the first
|
||||
/// 5 entries in the leaderboard. If The current user has no entry, this will return null.
|
||||
/// </summary>
|
||||
public async Task<LeaderboardEntry[]> GetScoresAroundUserAsync( int start = -10, int end = 10 )
|
||||
public async Task<LeaderboardEntry[]?> GetScoresAroundUserAsync( int start = -10, int end = 10 )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
var r = await SteamUserStats.Internal.DownloadLeaderboardEntries( Id, LeaderboardDataRequest.GlobalAroundUser, start, end );
|
||||
if ( !r.HasValue )
|
||||
return null;
|
||||
@@ -106,8 +112,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Used to retrieve all leaderboard entries for friends of the current user
|
||||
/// </summary>
|
||||
public async Task<LeaderboardEntry[]> GetScoresFromFriendsAsync()
|
||||
public async Task<LeaderboardEntry[]?> GetScoresFromFriendsAsync()
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
var r = await SteamUserStats.Internal.DownloadLeaderboardEntries( Id, LeaderboardDataRequest.Friends, 0, 0 );
|
||||
if ( !r.HasValue )
|
||||
return null;
|
||||
@@ -116,8 +123,9 @@ namespace Steamworks.Data
|
||||
}
|
||||
|
||||
#region util
|
||||
internal async Task<LeaderboardEntry[]> LeaderboardResultToEntries( LeaderboardScoresDownloaded_t r )
|
||||
internal async Task<LeaderboardEntry[]?> LeaderboardResultToEntries( LeaderboardScoresDownloaded_t r )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
if ( r.CEntryCount <= 0 )
|
||||
return null;
|
||||
|
||||
@@ -142,6 +150,8 @@ namespace Steamworks.Data
|
||||
bool gotAll = false;
|
||||
while ( !gotAll )
|
||||
{
|
||||
if (SteamFriends.Internal is null) { return; }
|
||||
|
||||
gotAll = true;
|
||||
|
||||
foreach ( var entry in entries )
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Steamworks.Data
|
||||
public Friend User;
|
||||
public int GlobalRank;
|
||||
public int Score;
|
||||
public int[] Details;
|
||||
public int[]? Details;
|
||||
// UGCHandle_t m_hUGC
|
||||
|
||||
internal static LeaderboardEntry From( LeaderboardEntry_t e, int[] detailsBuffer )
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public async Task<RoomEnter> Join()
|
||||
{
|
||||
if (SteamMatchmaking.Internal is null) { return RoomEnter.Error; }
|
||||
|
||||
var result = await SteamMatchmaking.Internal.JoinLobby( Id );
|
||||
if ( !result.HasValue ) return RoomEnter.Error;
|
||||
|
||||
@@ -35,7 +37,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void Leave()
|
||||
{
|
||||
SteamMatchmaking.Internal.LeaveLobby( Id );
|
||||
SteamMatchmaking.Internal?.LeaveLobby( Id );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -45,13 +47,13 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool InviteFriend( SteamId steamid )
|
||||
{
|
||||
return SteamMatchmaking.Internal.InviteUserToLobby( Id, steamid );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.InviteUserToLobby( Id, steamid );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the number of users in the specified lobby
|
||||
/// </summary>
|
||||
public int MemberCount => SteamMatchmaking.Internal.GetNumLobbyMembers( Id );
|
||||
public int MemberCount => SteamMatchmaking.Internal?.GetNumLobbyMembers( Id ) ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Returns current members. Need to be in the lobby to see the users.
|
||||
@@ -62,6 +64,7 @@ namespace Steamworks.Data
|
||||
{
|
||||
for( int i = 0; i < MemberCount; i++ )
|
||||
{
|
||||
if (SteamMatchmaking.Internal is null) { break; }
|
||||
yield return new Friend( SteamMatchmaking.Internal.GetLobbyMemberByIndex( Id, i ) );
|
||||
}
|
||||
}
|
||||
@@ -71,9 +74,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Get data associated with this lobby
|
||||
/// </summary>
|
||||
public string GetData( string key )
|
||||
public string? GetData( string key )
|
||||
{
|
||||
return SteamMatchmaking.Internal.GetLobbyData( Id, key );
|
||||
return SteamMatchmaking.Internal?.GetLobbyData( Id, key );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +87,7 @@ namespace Steamworks.Data
|
||||
if ( key.Length > 255 ) throw new System.ArgumentException( "Key should be < 255 chars", nameof( key ) );
|
||||
if ( value.Length > 8192 ) throw new System.ArgumentException( "Value should be < 8192 chars", nameof( key ) );
|
||||
|
||||
return SteamMatchmaking.Internal.SetLobbyData( Id, key, value );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyData( Id, key, value );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +95,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool DeleteData( string key )
|
||||
{
|
||||
return SteamMatchmaking.Internal.DeleteLobbyData( Id, key );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.DeleteLobbyData( Id, key );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -102,10 +105,11 @@ namespace Steamworks.Data
|
||||
{
|
||||
get
|
||||
{
|
||||
var cnt = SteamMatchmaking.Internal.GetLobbyDataCount( Id );
|
||||
var cnt = SteamMatchmaking.Internal?.GetLobbyDataCount( Id ) ?? 0;
|
||||
|
||||
for ( int i =0; i<cnt; i++)
|
||||
{
|
||||
if (SteamMatchmaking.Internal is null) { break; }
|
||||
if ( SteamMatchmaking.Internal.GetLobbyDataByIndex( Id, i, out var a, out var b ) )
|
||||
{
|
||||
yield return new KeyValuePair<string, string>( a, b );
|
||||
@@ -117,9 +121,9 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Gets per-user metadata for someone in this lobby
|
||||
/// </summary>
|
||||
public string GetMemberData( Friend member, string key )
|
||||
public string? GetMemberData( Friend member, string key )
|
||||
{
|
||||
return SteamMatchmaking.Internal.GetLobbyMemberData( Id, member.Id, key );
|
||||
return SteamMatchmaking.Internal?.GetLobbyMemberData( Id, member.Id, key );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -127,7 +131,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void SetMemberData( string key, string value )
|
||||
{
|
||||
SteamMatchmaking.Internal.SetLobbyMemberData( Id, key, value );
|
||||
SteamMatchmaking.Internal?.SetLobbyMemberData( Id, key, value );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -148,7 +152,7 @@ namespace Steamworks.Data
|
||||
{
|
||||
fixed ( byte* ptr = data )
|
||||
{
|
||||
return SteamMatchmaking.Internal.SendLobbyChatMsg( Id, (IntPtr)ptr, data.Length );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SendLobbyChatMsg( Id, (IntPtr)ptr, data.Length );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +167,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool Refresh()
|
||||
{
|
||||
return SteamMatchmaking.Internal.RequestLobbyData( Id );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.RequestLobbyData( Id );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -172,33 +176,33 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public int MaxMembers
|
||||
{
|
||||
get => SteamMatchmaking.Internal.GetLobbyMemberLimit( Id );
|
||||
set => SteamMatchmaking.Internal.SetLobbyMemberLimit( Id, value );
|
||||
get => SteamMatchmaking.Internal?.GetLobbyMemberLimit( Id ) ?? 0;
|
||||
set => SteamMatchmaking.Internal?.SetLobbyMemberLimit( Id, value );
|
||||
}
|
||||
|
||||
public bool SetPublic()
|
||||
{
|
||||
return SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Public );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Public );
|
||||
}
|
||||
|
||||
public bool SetPrivate()
|
||||
{
|
||||
return SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Private );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Private );
|
||||
}
|
||||
|
||||
public bool SetInvisible()
|
||||
{
|
||||
return SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Invisible );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.Invisible );
|
||||
}
|
||||
|
||||
public bool SetFriendsOnly()
|
||||
{
|
||||
return SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.FriendsOnly );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyType( Id, LobbyType.FriendsOnly );
|
||||
}
|
||||
|
||||
public bool SetJoinable( bool b )
|
||||
{
|
||||
return SteamMatchmaking.Internal.SetLobbyJoinable( Id, b );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.SetLobbyJoinable( Id, b );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -211,7 +215,7 @@ namespace Steamworks.Data
|
||||
if ( !steamServer.IsValid )
|
||||
throw new ArgumentException( $"SteamId for server is invalid" );
|
||||
|
||||
SteamMatchmaking.Internal.SetLobbyGameServer( Id, 0, 0, steamServer );
|
||||
SteamMatchmaking.Internal?.SetLobbyGameServer( Id, 0, 0, steamServer );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -224,7 +228,7 @@ namespace Steamworks.Data
|
||||
if ( !IPAddress.TryParse( ip, out IPAddress add ) )
|
||||
throw new ArgumentException( $"IP address for server is invalid" );
|
||||
|
||||
SteamMatchmaking.Internal.SetLobbyGameServer( Id, add.IpToInt32(), port, new SteamId() );
|
||||
SteamMatchmaking.Internal?.SetLobbyGameServer( Id, add.IpToInt32(), port, new SteamId() );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -233,7 +237,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool GetGameServer( ref uint ip, ref ushort port, ref SteamId serverId )
|
||||
{
|
||||
return SteamMatchmaking.Internal.GetLobbyGameServer( Id, ref ip, ref port, ref serverId );
|
||||
return SteamMatchmaking.Internal != null && SteamMatchmaking.Internal.GetLobbyGameServer( Id, ref ip, ref port, ref serverId );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -241,8 +245,8 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public Friend Owner
|
||||
{
|
||||
get => new Friend( SteamMatchmaking.Internal.GetLobbyOwner( Id ) );
|
||||
set => SteamMatchmaking.Internal.SetLobbyOwner( Id, value.Id );
|
||||
get => new Friend( SteamMatchmaking.Internal?.GetLobbyOwner( Id ) ?? 0 );
|
||||
set => SteamMatchmaking.Internal?.SetLobbyOwner( Id, value.Id );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -197,6 +197,8 @@ namespace Steamworks.Data
|
||||
|
||||
void ApplyFilters()
|
||||
{
|
||||
if (SteamMatchmaking.Internal is null) { return; }
|
||||
|
||||
if ( distance.HasValue )
|
||||
{
|
||||
SteamMatchmaking.Internal.AddRequestLobbyListDistanceFilter( distance.Value );
|
||||
@@ -251,8 +253,10 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Run the query, get the matching lobbies
|
||||
/// </summary>
|
||||
public async Task<Lobby[]> RequestAsync()
|
||||
public async Task<Lobby[]?> RequestAsync()
|
||||
{
|
||||
if (SteamMatchmaking.Internal is null) { return null; }
|
||||
|
||||
await Task.Yield();
|
||||
ApplyFilters();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Steamworks
|
||||
{
|
||||
public struct PartyBeacon
|
||||
{
|
||||
static ISteamParties Internal => SteamParties.Internal;
|
||||
static ISteamParties? Internal => SteamParties.Internal;
|
||||
|
||||
internal PartyBeaconID_t Id;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Steamworks
|
||||
{
|
||||
var owner = default( SteamId );
|
||||
var location = default( SteamPartyBeaconLocation_t );
|
||||
Internal.GetBeaconDetails( Id, ref owner, ref location, out _ );
|
||||
Internal?.GetBeaconDetails( Id, ref owner, ref location, out _ );
|
||||
return owner;
|
||||
}
|
||||
}
|
||||
@@ -26,13 +26,14 @@ namespace Steamworks
|
||||
/// <summary>
|
||||
/// Creator of the beacon
|
||||
/// </summary>
|
||||
public string MetaData
|
||||
public string? MetaData
|
||||
{
|
||||
get
|
||||
{
|
||||
var owner = default( SteamId );
|
||||
var location = default( SteamPartyBeaconLocation_t );
|
||||
_ = Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal );
|
||||
string? strVal = null;
|
||||
_ = Internal?.GetBeaconDetails( Id, ref owner, ref location, out strVal );
|
||||
return strVal;
|
||||
}
|
||||
}
|
||||
@@ -41,8 +42,10 @@ namespace Steamworks
|
||||
/// Will attempt to join the party. If successful will return a connection string.
|
||||
/// If failed, will return null
|
||||
/// </summary>
|
||||
public async Task<string> JoinAsync()
|
||||
public async Task<string?> JoinAsync()
|
||||
{
|
||||
if (Internal is null) { return null; }
|
||||
|
||||
var result = await Internal.JoinParty( Id );
|
||||
if ( !result.HasValue || result.Value.Result != Result.OK )
|
||||
return null;
|
||||
@@ -56,7 +59,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public void OnReservationCompleted( SteamId steamid )
|
||||
{
|
||||
Internal.OnReservationCompleted( Id, steamid );
|
||||
Internal?.OnReservationCompleted( Id, steamid );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +69,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public void CancelReservation( SteamId steamid )
|
||||
{
|
||||
Internal.CancelReservation( Id, steamid );
|
||||
Internal?.CancelReservation( Id, steamid );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,7 +77,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public bool Destroy()
|
||||
{
|
||||
return Internal.DestroyBeacon( Id );
|
||||
return Internal != null && Internal.DestroyBeacon( Id );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,16 +23,16 @@ namespace Steamworks.Data
|
||||
/// <summary>
|
||||
/// Get the SteamID of the connected user
|
||||
/// </summary>
|
||||
public SteamId SteamId => SteamRemotePlay.Internal.GetSessionSteamID( Id );
|
||||
public SteamId SteamId => SteamRemotePlay.Internal?.GetSessionSteamID( Id ) ?? default;
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the session client device
|
||||
/// </summary>
|
||||
public string ClientName => SteamRemotePlay.Internal.GetSessionClientName( Id );
|
||||
public string? ClientName => SteamRemotePlay.Internal?.GetSessionClientName( Id );
|
||||
|
||||
/// <summary>
|
||||
/// Get the name of the session client device
|
||||
/// </summary>
|
||||
public SteamDeviceFormFactor FormFactor => SteamRemotePlay.Internal.GetSessionClientFormFactor( Id );
|
||||
public SteamDeviceFormFactor FormFactor => SteamRemotePlay.Internal?.GetSessionClientFormFactor( Id ) ?? SteamDeviceFormFactor.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool TagUser( SteamId user )
|
||||
{
|
||||
return SteamScreenshots.Internal.TagUser( Value, user );
|
||||
return SteamScreenshots.Internal != null && SteamScreenshots.Internal.TagUser( Value, user );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -23,7 +23,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool SetLocation( string location )
|
||||
{
|
||||
return SteamScreenshots.Internal.SetLocation( Value, location );
|
||||
return SteamScreenshots.Internal != null && SteamScreenshots.Internal.SetLocation( Value, location );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -31,7 +31,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public bool TagPublishedFile( PublishedFileId file )
|
||||
{
|
||||
return SteamScreenshots.Internal.TagPublishedFile( Value, file );
|
||||
return SteamScreenshots.Internal != null && SteamScreenshots.Internal.TagPublishedFile( Value, file );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@ namespace Steamworks.Data
|
||||
{
|
||||
public struct ServerInfo : IEquatable<ServerInfo>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int Ping { get; set; }
|
||||
public string GameDir { get; set; }
|
||||
public string Map { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string? GameDir { get; set; }
|
||||
public string? Map { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public uint AppId { get; set; }
|
||||
public int Players { get; set; }
|
||||
public int MaxPlayers { get; set; }
|
||||
@@ -22,19 +22,19 @@ namespace Steamworks.Data
|
||||
public bool Secure { get; set; }
|
||||
public uint LastTimePlayed { get; set; }
|
||||
public int Version { get; set; }
|
||||
public string TagString { get; set; }
|
||||
public string? TagString { get; set; }
|
||||
public ulong SteamId { get; set; }
|
||||
public uint AddressRaw { get; set; }
|
||||
public IPAddress Address { get; set; }
|
||||
public IPAddress? Address { get; set; }
|
||||
public int ConnectionPort { get; set; }
|
||||
public int QueryPort { get; set; }
|
||||
|
||||
string[] _tags;
|
||||
string[]? _tags;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the individual tags for this server
|
||||
/// </summary>
|
||||
public string[] Tags
|
||||
public string[]? Tags
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -97,13 +97,13 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void AddToHistory()
|
||||
{
|
||||
SteamMatchmaking.Internal.AddFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagHistory, (uint)Epoch.Current );
|
||||
SteamMatchmaking.Internal?.AddFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagHistory, (uint)Epoch.Current );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If this server responds to source engine style queries, we'll be able to get a list of rules here
|
||||
/// </summary>
|
||||
public async Task<Dictionary<string, string>> QueryRulesAsync()
|
||||
public async Task<Dictionary<string, string>?> QueryRulesAsync()
|
||||
{
|
||||
return await SourceServerQuery.GetRules( this );
|
||||
}
|
||||
@@ -113,7 +113,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void RemoveFromHistory()
|
||||
{
|
||||
SteamMatchmaking.Internal.RemoveFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagHistory );
|
||||
SteamMatchmaking.Internal?.RemoveFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagHistory );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,7 +121,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void AddToFavourites()
|
||||
{
|
||||
SteamMatchmaking.Internal.AddFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagFavorite, (uint)Epoch.Current );
|
||||
SteamMatchmaking.Internal?.AddFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagFavorite, (uint)Epoch.Current );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -129,7 +129,7 @@ namespace Steamworks.Data
|
||||
/// </summary>
|
||||
public void RemoveFromFavourites()
|
||||
{
|
||||
SteamMatchmaking.Internal.RemoveFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagFavorite );
|
||||
SteamMatchmaking.Internal?.RemoveFavoriteGame( SteamClient.AppId, AddressRaw, (ushort)ConnectionPort, (ushort)QueryPort, k_unFavoriteFlagFavorite );
|
||||
}
|
||||
|
||||
public bool Equals( ServerInfo other )
|
||||
@@ -139,7 +139,7 @@ namespace Steamworks.Data
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Address.GetHashCode() + SteamId.GetHashCode() + ConnectionPort.GetHashCode() + QueryPort.GetHashCode();
|
||||
return (Address?.GetHashCode() ?? 0) + SteamId.GetHashCode() + ConnectionPort.GetHashCode() + QueryPort.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public struct SteamServerInit
|
||||
{
|
||||
public IPAddress IpAddress;
|
||||
public IPAddress? IpAddress;
|
||||
public ushort SteamPort;
|
||||
public ushort GamePort;
|
||||
public ushort QueryPort;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Steamworks.Data
|
||||
UserId = user;
|
||||
}
|
||||
|
||||
internal void LocalUserOnly( [CallerMemberName] string caller = null )
|
||||
internal void LocalUserOnly( [CallerMemberName] string? caller = null )
|
||||
{
|
||||
if ( UserId == 0 ) return;
|
||||
throw new System.Exception( $"Stat.{caller} can only be called for the local user" );
|
||||
@@ -36,7 +36,7 @@ namespace Steamworks.Data
|
||||
{
|
||||
double val = 0.0;
|
||||
|
||||
if ( SteamUserStats.Internal.GetGlobalStat( Name, ref val ) )
|
||||
if ( SteamUserStats.Internal != null && SteamUserStats.Internal.GetGlobalStat( Name, ref val ) )
|
||||
return val;
|
||||
|
||||
return 0;
|
||||
@@ -45,12 +45,14 @@ namespace Steamworks.Data
|
||||
public long GetGlobalInt()
|
||||
{
|
||||
long val = 0;
|
||||
SteamUserStats.Internal.GetGlobalStat( Name, ref val );
|
||||
SteamUserStats.Internal?.GetGlobalStat( Name, ref val );
|
||||
return val;
|
||||
}
|
||||
|
||||
public async Task<long[]> GetGlobalIntDaysAsync( int days )
|
||||
public async Task<long[]?> GetGlobalIntDaysAsync( int days )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
|
||||
var result = await SteamUserStats.Internal.RequestGlobalStats( days );
|
||||
if ( result?.Result != Result.OK ) return null;
|
||||
|
||||
@@ -64,8 +66,10 @@ namespace Steamworks.Data
|
||||
return r;
|
||||
}
|
||||
|
||||
public async Task<double[]> GetGlobalFloatDays( int days )
|
||||
public async Task<double[]?> GetGlobalFloatDays( int days )
|
||||
{
|
||||
if (SteamUserStats.Internal is null) { return null; }
|
||||
|
||||
var result = await SteamUserStats.Internal.RequestGlobalStats( days );
|
||||
if ( result?.Result != Result.OK ) return null;
|
||||
|
||||
@@ -85,14 +89,14 @@ namespace Steamworks.Data
|
||||
|
||||
if ( UserId > 0 )
|
||||
{
|
||||
SteamUserStats.Internal.GetUserStat( UserId, Name, ref val );
|
||||
SteamUserStats.Internal?.GetUserStat( UserId, Name, ref val );
|
||||
}
|
||||
else
|
||||
{
|
||||
SteamUserStats.Internal.GetStat( Name, ref val );
|
||||
SteamUserStats.Internal?.GetStat( Name, ref val );
|
||||
}
|
||||
|
||||
return 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
public int GetInt()
|
||||
@@ -101,11 +105,11 @@ namespace Steamworks.Data
|
||||
|
||||
if ( UserId > 0 )
|
||||
{
|
||||
SteamUserStats.Internal.GetUserStat( UserId, Name, ref val );
|
||||
SteamUserStats.Internal?.GetUserStat( UserId, Name, ref val );
|
||||
}
|
||||
else
|
||||
{
|
||||
SteamUserStats.Internal.GetStat( Name, ref val );
|
||||
SteamUserStats.Internal?.GetStat( Name, ref val );
|
||||
}
|
||||
|
||||
return val;
|
||||
@@ -114,13 +118,13 @@ namespace Steamworks.Data
|
||||
public bool Set( int val )
|
||||
{
|
||||
LocalUserOnly();
|
||||
return SteamUserStats.Internal.SetStat( Name, val );
|
||||
return SteamUserStats.Internal != null && SteamUserStats.Internal.SetStat( Name, val );
|
||||
}
|
||||
|
||||
public bool Set( float val )
|
||||
{
|
||||
LocalUserOnly();
|
||||
return SteamUserStats.Internal.SetStat( Name, val );
|
||||
return SteamUserStats.Internal != null && SteamUserStats.Internal.SetStat( Name, val );
|
||||
}
|
||||
|
||||
public bool Add( int val )
|
||||
@@ -138,13 +142,13 @@ namespace Steamworks.Data
|
||||
public bool UpdateAverageRate( float count, float sessionlength )
|
||||
{
|
||||
LocalUserOnly();
|
||||
return SteamUserStats.Internal.UpdateAvgRateStat( Name, count, sessionlength );
|
||||
return SteamUserStats.Internal != null && SteamUserStats.Internal.UpdateAvgRateStat( Name, count, sessionlength );
|
||||
}
|
||||
|
||||
public bool Store()
|
||||
{
|
||||
LocalUserOnly();
|
||||
return SteamUserStats.Internal.StoreStats();
|
||||
return SteamUserStats.Internal != null && SteamUserStats.Internal.StoreStats();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,25 +47,25 @@ namespace Steamworks.Ugc
|
||||
|
||||
public Editor ForAppId( AppId id ) { this.consumerAppId = id; return this; }
|
||||
|
||||
public string Title { get; private set; }
|
||||
public string? Title { get; private set; }
|
||||
public Editor WithTitle( string t ) { this.Title = t; return this; }
|
||||
|
||||
public string Description { get; private set; }
|
||||
public string? Description { get; private set; }
|
||||
public Editor WithDescription( string t ) { this.Description = t; return this; }
|
||||
|
||||
string MetaData;
|
||||
string? MetaData;
|
||||
public Editor WithMetaData( string t ) { this.MetaData = t; return this; }
|
||||
|
||||
string ChangeLog;
|
||||
string? ChangeLog;
|
||||
public Editor WithChangeLog( string t ) { this.ChangeLog = t; return this; }
|
||||
|
||||
string Language;
|
||||
string? Language;
|
||||
public Editor InLanguage( string t ) { this.Language = t; return this; }
|
||||
|
||||
public string PreviewFile { get; private set; }
|
||||
public Editor WithPreviewFile( string t ) { this.PreviewFile = t; return this; }
|
||||
public string? PreviewFile { get; private set; }
|
||||
public Editor WithPreviewFile( string? t ) { this.PreviewFile = t; return this; }
|
||||
|
||||
public System.IO.DirectoryInfo ContentFolder { get; private set; }
|
||||
public System.IO.DirectoryInfo? ContentFolder { get; private set; }
|
||||
public Editor WithContent( System.IO.DirectoryInfo t ) { this.ContentFolder = t; return this; }
|
||||
public Editor WithContent( string folderName ) { return WithContent( new System.IO.DirectoryInfo( folderName ) ); }
|
||||
|
||||
@@ -73,9 +73,9 @@ namespace Steamworks.Ugc
|
||||
|
||||
public Editor WithVisibility(Visibility visibility) { Visibility = visibility; return this; }
|
||||
|
||||
public List<string> Tags { get; private set; }
|
||||
Dictionary<string, List<string>> keyValueTags;
|
||||
HashSet<string> keyValueTagsToRemove;
|
||||
public List<string>? Tags { get; private set; }
|
||||
Dictionary<string, List<string>>? keyValueTags;
|
||||
HashSet<string>? keyValueTagsToRemove;
|
||||
|
||||
public Editor WithTag( string tag )
|
||||
{
|
||||
@@ -143,9 +143,10 @@ namespace Steamworks.Ugc
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<PublishResult> SubmitAsync( IProgress<float> progress = null )
|
||||
public async Task<PublishResult> SubmitAsync( IProgress<float>? progress = null )
|
||||
{
|
||||
var result = default( PublishResult );
|
||||
if (SteamUGC.Internal is null) { return result; }
|
||||
|
||||
progress?.Report( 0 );
|
||||
|
||||
|
||||
@@ -35,22 +35,22 @@ namespace Steamworks.Ugc
|
||||
/// <summary>
|
||||
/// The given title of this item
|
||||
/// </summary>
|
||||
public string Title { get; internal set; }
|
||||
public string? Title { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The description of this item, in your local language if available
|
||||
/// </summary>
|
||||
public string Description { get; internal set; }
|
||||
public string? Description { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of tags for this item, all lowercase
|
||||
/// </summary>
|
||||
public string[] Tags { get; internal set; }
|
||||
public string[]? Tags { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary of key value tags for this item, only available from queries WithKeyValueTags(true)
|
||||
/// </summary>
|
||||
public Dictionary<string,string> KeyValueTags { get; internal set; }
|
||||
public Dictionary<string,string>? KeyValueTags { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// App Id of the app that created this item
|
||||
@@ -123,14 +123,14 @@ namespace Steamworks.Ugc
|
||||
public bool IsSubscribed => (State & ItemState.Subscribed) == ItemState.Subscribed;
|
||||
public bool NeedsUpdate => (State & ItemState.NeedsUpdate) == ItemState.NeedsUpdate;
|
||||
|
||||
public string Directory
|
||||
public string? Directory
|
||||
{
|
||||
get
|
||||
{
|
||||
ulong size = 0;
|
||||
uint ts = 0;
|
||||
|
||||
if (SteamUGC.Internal.GetItemInstallInfo(Id, ref size, out var strVal, ref ts)) { return strVal; }
|
||||
if (SteamUGC.Internal != null && SteamUGC.Internal.GetItemInstallInfo(Id, ref size, out var strVal, ref ts)) { return strVal; }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ namespace Steamworks.Ugc
|
||||
|
||||
ulong downloaded = 0;
|
||||
ulong total = 0;
|
||||
if ( SteamUGC.Internal.GetItemDownloadInfo( Id, ref downloaded, ref total ) )
|
||||
if ( SteamUGC.Internal != null && SteamUGC.Internal.GetItemDownloadInfo( Id, ref downloaded, ref total ) )
|
||||
return (long) total;
|
||||
|
||||
return -1;
|
||||
@@ -166,7 +166,7 @@ namespace Steamworks.Ugc
|
||||
|
||||
ulong downloaded = 0;
|
||||
ulong total = 0;
|
||||
if ( SteamUGC.Internal.GetItemDownloadInfo( Id, ref downloaded, ref total ) )
|
||||
if ( SteamUGC.Internal != null && SteamUGC.Internal.GetItemDownloadInfo( Id, ref downloaded, ref total ) )
|
||||
return (long)downloaded;
|
||||
|
||||
return -1;
|
||||
@@ -185,7 +185,7 @@ namespace Steamworks.Ugc
|
||||
|
||||
ulong size = 0;
|
||||
uint ts = 0;
|
||||
if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) )
|
||||
if ( SteamUGC.Internal is null || !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) )
|
||||
return 0;
|
||||
|
||||
return (long) size;
|
||||
@@ -201,7 +201,7 @@ namespace Steamworks.Ugc
|
||||
{
|
||||
ulong size = 0;
|
||||
uint ts = 0;
|
||||
if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) )
|
||||
if ( SteamUGC.Internal is null || !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) )
|
||||
return null;
|
||||
|
||||
return Epoch.ToDateTime(ts);
|
||||
@@ -226,7 +226,7 @@ namespace Steamworks.Ugc
|
||||
//possibly similar properties should also be changed
|
||||
ulong downloaded = 0;
|
||||
ulong total = 0;
|
||||
if (SteamUGC.Internal.GetItemDownloadInfo(Id, ref downloaded, ref total) && total > 0)
|
||||
if (SteamUGC.Internal != null && SteamUGC.Internal.GetItemDownloadInfo(Id, ref downloaded, ref total) && total > 0)
|
||||
{
|
||||
return (float)((double)downloaded / (double)total);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public bool HasTag( string find )
|
||||
{
|
||||
if ( Tags.Length == 0 ) return false;
|
||||
if ( Tags is null || Tags.Length == 0 ) return false;
|
||||
|
||||
return Tags.Contains( find, StringComparer.OrdinalIgnoreCase );
|
||||
}
|
||||
@@ -287,6 +287,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public async Task<bool> Subscribe ()
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return false; }
|
||||
var result = await SteamUGC.Internal.SubscribeItem( _id );
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
@@ -296,7 +297,7 @@ namespace Steamworks.Ugc
|
||||
/// If CancellationToken is default then there is 60 seconds timeout
|
||||
/// Progress will be set to 0-1
|
||||
/// </summary>
|
||||
public async Task<bool> DownloadAsync( Action<float> progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default )
|
||||
public async Task<bool> DownloadAsync( Action<float>? progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default )
|
||||
{
|
||||
return await SteamUGC.DownloadAsync( Id, progress, milisecondsUpdateDelay, ct );
|
||||
}
|
||||
@@ -305,7 +306,8 @@ namespace Steamworks.Ugc
|
||||
/// Allows the user to unsubscribe from this item
|
||||
/// </summary>
|
||||
public async Task<bool> Unsubscribe ()
|
||||
{
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return false; }
|
||||
var result = await SteamUGC.Internal.UnsubscribeItem( _id );
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
@@ -315,6 +317,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public async Task<bool> AddFavorite()
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return false; }
|
||||
var result = await SteamUGC.Internal.AddItemToFavorites(details.ConsumerAppID, _id);
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
@@ -324,6 +327,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public async Task<bool> RemoveFavorite()
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return false; }
|
||||
var result = await SteamUGC.Internal.RemoveItemFromFavorites(details.ConsumerAppID, _id);
|
||||
return result?.Result == Result.OK;
|
||||
}
|
||||
@@ -333,6 +337,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public async Task<Result?> Vote( bool up )
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return null; }
|
||||
var r = await SteamUGC.Internal.SetUserItemVote( Id, up );
|
||||
return r?.Result;
|
||||
}
|
||||
@@ -342,6 +347,7 @@ namespace Steamworks.Ugc
|
||||
/// </summary>
|
||||
public async Task<UserItemVote?> GetUserVote()
|
||||
{
|
||||
if (SteamUGC.Internal is null) { return null; }
|
||||
var result = await SteamUGC.Internal.GetUserItemVote(_id);
|
||||
if (!result.HasValue)
|
||||
return null;
|
||||
@@ -351,27 +357,27 @@ namespace Steamworks.Ugc
|
||||
/// <summary>
|
||||
/// Return a URL to view this item online
|
||||
/// </summary>
|
||||
public string Url => $"http://steamcommunity.com/sharedfiles/filedetails/?source=Facepunch.Steamworks&id={Id}";
|
||||
public string Url => $"https://steamcommunity.com/sharedfiles/filedetails/?source=Facepunch.Steamworks&id={Id}";
|
||||
|
||||
/// <summary>
|
||||
/// The URl to view this item's changelog
|
||||
/// </summary>
|
||||
public string ChangelogUrl => $"http://steamcommunity.com/sharedfiles/filedetails/changelog/{Id}";
|
||||
public string ChangelogUrl => $"https://steamcommunity.com/sharedfiles/filedetails/changelog/{Id}";
|
||||
|
||||
/// <summary>
|
||||
/// The URL to view the comments on this item
|
||||
/// </summary>
|
||||
public string CommentsUrl => $"http://steamcommunity.com/sharedfiles/filedetails/comments/{Id}";
|
||||
public string CommentsUrl => $"https://steamcommunity.com/sharedfiles/filedetails/comments/{Id}";
|
||||
|
||||
/// <summary>
|
||||
/// The URL to discuss this item
|
||||
/// </summary>
|
||||
public string DiscussUrl => $"http://steamcommunity.com/sharedfiles/filedetails/discussions/{Id}";
|
||||
public string DiscussUrl => $"https://steamcommunity.com/sharedfiles/filedetails/discussions/{Id}";
|
||||
|
||||
/// <summary>
|
||||
/// The URL to view this items stats online
|
||||
/// </summary>
|
||||
public string StatsUrl => $"http://steamcommunity.com/sharedfiles/filedetails/stats/{Id}";
|
||||
public string StatsUrl => $"https://steamcommunity.com/sharedfiles/filedetails/stats/{Id}";
|
||||
|
||||
public ulong NumSubscriptions { get; internal set; }
|
||||
public ulong NumFavorites { get; internal set; }
|
||||
@@ -390,12 +396,12 @@ namespace Steamworks.Ugc
|
||||
/// <summary>
|
||||
/// The URL to the preview image for this item
|
||||
/// </summary>
|
||||
public string PreviewImageUrl { get; internal set; }
|
||||
public string? PreviewImageUrl { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The metadata string for this item, only available from queries WithMetadata(true)
|
||||
/// </summary>
|
||||
public string Metadata { get; internal set; }
|
||||
public string? Metadata { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Edit this item
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Steamworks.Ugc
|
||||
UGCQuery queryType;
|
||||
AppId consumerApp;
|
||||
AppId creatorApp;
|
||||
string searchText;
|
||||
string? searchText;
|
||||
|
||||
public Query( UgcType type ) : this()
|
||||
{
|
||||
@@ -96,7 +96,7 @@ namespace Steamworks.Ugc
|
||||
#endregion
|
||||
|
||||
#region Files
|
||||
PublishedFileId[] Files;
|
||||
PublishedFileId[]? Files;
|
||||
|
||||
public Query WithFileId( params PublishedFileId[] files )
|
||||
{
|
||||
@@ -109,6 +109,8 @@ namespace Steamworks.Ugc
|
||||
{
|
||||
if ( page <= 0 ) throw new System.Exception( "page should be > 0" );
|
||||
|
||||
if (SteamUGC.Internal is null) { return null; }
|
||||
|
||||
if ( consumerApp == 0 ) consumerApp = SteamClient.AppId;
|
||||
if ( creatorApp == 0 ) creatorApp = consumerApp;
|
||||
|
||||
@@ -159,16 +161,16 @@ namespace Steamworks.Ugc
|
||||
public QueryType WithType( UgcType type ) { matchingType = type; return this; }
|
||||
int? maxCacheAge;
|
||||
public QueryType AllowCachedResponse( int maxSecondsAge ) { maxCacheAge = maxSecondsAge; return this; }
|
||||
string language;
|
||||
string? language;
|
||||
public QueryType InLanguage( string lang ) { language = lang; return this; }
|
||||
|
||||
int? trendDays;
|
||||
public QueryType WithTrendDays( int days ) { trendDays = days; return this; }
|
||||
|
||||
List<string> requiredTags;
|
||||
List<string>? requiredTags;
|
||||
bool? matchAnyTag;
|
||||
List<string> excludedTags;
|
||||
Dictionary<string, string> requiredKv;
|
||||
List<string>? excludedTags;
|
||||
Dictionary<string, string>? requiredKv;
|
||||
|
||||
/// <summary>
|
||||
/// Found items must have at least one of the defined tags
|
||||
@@ -213,34 +215,34 @@ namespace Steamworks.Ugc
|
||||
if ( requiredTags != null )
|
||||
{
|
||||
foreach ( var tag in requiredTags )
|
||||
SteamUGC.Internal.AddRequiredTag( handle, tag );
|
||||
SteamUGC.Internal?.AddRequiredTag( handle, tag );
|
||||
}
|
||||
|
||||
if ( excludedTags != null )
|
||||
{
|
||||
foreach ( var tag in excludedTags )
|
||||
SteamUGC.Internal.AddExcludedTag( handle, tag );
|
||||
SteamUGC.Internal?.AddExcludedTag( handle, tag );
|
||||
}
|
||||
|
||||
if ( requiredKv != null )
|
||||
{
|
||||
foreach ( var tag in requiredKv )
|
||||
SteamUGC.Internal.AddRequiredKeyValueTag( handle, tag.Key, tag.Value );
|
||||
SteamUGC.Internal?.AddRequiredKeyValueTag( handle, tag.Key, tag.Value );
|
||||
}
|
||||
|
||||
if ( matchAnyTag.HasValue )
|
||||
{
|
||||
SteamUGC.Internal.SetMatchAnyTag( handle, matchAnyTag.Value );
|
||||
SteamUGC.Internal?.SetMatchAnyTag( handle, matchAnyTag.Value );
|
||||
}
|
||||
|
||||
if ( trendDays.HasValue )
|
||||
{
|
||||
SteamUGC.Internal.SetRankedByTrendDays( handle, (uint)trendDays.Value );
|
||||
SteamUGC.Internal?.SetRankedByTrendDays( handle, (uint)trendDays.Value );
|
||||
}
|
||||
|
||||
if ( !string.IsNullOrEmpty( searchText ) )
|
||||
{
|
||||
SteamUGC.Internal.SetSearchText( handle, searchText );
|
||||
SteamUGC.Internal?.SetSearchText( handle, searchText );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,42 +273,42 @@ namespace Steamworks.Ugc
|
||||
{
|
||||
if (WantsReturnOnlyIDs.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnOnlyIDs(handle, WantsReturnOnlyIDs.Value);
|
||||
SteamUGC.Internal?.SetReturnOnlyIDs(handle, WantsReturnOnlyIDs.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnKeyValueTags.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnKeyValueTags(handle, WantsReturnKeyValueTags.Value);
|
||||
SteamUGC.Internal?.SetReturnKeyValueTags(handle, WantsReturnKeyValueTags.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnLongDescription.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnLongDescription(handle, WantsReturnLongDescription.Value);
|
||||
SteamUGC.Internal?.SetReturnLongDescription(handle, WantsReturnLongDescription.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnMetadata.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnMetadata(handle, WantsReturnMetadata.Value);
|
||||
SteamUGC.Internal?.SetReturnMetadata(handle, WantsReturnMetadata.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnChildren.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnChildren(handle, WantsReturnChildren.Value);
|
||||
SteamUGC.Internal?.SetReturnChildren(handle, WantsReturnChildren.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnAdditionalPreviews.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnAdditionalPreviews(handle, WantsReturnAdditionalPreviews.Value);
|
||||
SteamUGC.Internal?.SetReturnAdditionalPreviews(handle, WantsReturnAdditionalPreviews.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnTotalOnly.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnTotalOnly(handle, WantsReturnTotalOnly.Value);
|
||||
SteamUGC.Internal?.SetReturnTotalOnly(handle, WantsReturnTotalOnly.Value);
|
||||
}
|
||||
|
||||
if (WantsReturnPlaytimeStats.HasValue)
|
||||
{
|
||||
SteamUGC.Internal.SetReturnPlaytimeStats(handle, WantsReturnPlaytimeStats.Value);
|
||||
SteamUGC.Internal?.SetReturnPlaytimeStats(handle, WantsReturnPlaytimeStats.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Steamworks.Ugc
|
||||
var details = default( SteamUGCDetails_t );
|
||||
for ( uint i=0; i< ResultCount; i++ )
|
||||
{
|
||||
if (SteamUGC.Internal is null) { yield break; }
|
||||
if ( SteamUGC.Internal.GetQueryUGCResult( Handle, i, ref details ) )
|
||||
{
|
||||
var item = Item.From( details );
|
||||
@@ -86,7 +87,7 @@ namespace Steamworks.Ugc
|
||||
{
|
||||
ulong val = 0;
|
||||
|
||||
if ( !SteamUGC.Internal.GetQueryUGCStatistic( Handle, index, stat, ref val ) )
|
||||
if ( SteamUGC.Internal is null || !SteamUGC.Internal.GetQueryUGCStatistic( Handle, index, stat, ref val ) )
|
||||
return 0;
|
||||
|
||||
return val;
|
||||
@@ -96,7 +97,7 @@ namespace Steamworks.Ugc
|
||||
{
|
||||
if ( Handle > 0 )
|
||||
{
|
||||
SteamUGC.Internal.ReleaseQueryUGCRequest( Handle );
|
||||
SteamUGC.Internal?.ReleaseQueryUGCRequest( Handle );
|
||||
Handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user