(965c31410) v0.10.4.0
This commit is contained in:
@@ -7,36 +7,22 @@ using Steamworks.Data;
|
||||
|
||||
namespace Steamworks
|
||||
{
|
||||
public static class SteamUserStats
|
||||
public class SteamUserStats : SteamClientClass<SteamUserStats>
|
||||
{
|
||||
static ISteamUserStats _internal;
|
||||
internal static ISteamUserStats Internal
|
||||
internal static ISteamUserStats Internal => Interface as ISteamUserStats;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
{
|
||||
get
|
||||
{
|
||||
SteamClient.ValidCheck();
|
||||
|
||||
if ( _internal == null )
|
||||
{
|
||||
_internal = new ISteamUserStats();
|
||||
_internal.Init();
|
||||
|
||||
RequestCurrentStats();
|
||||
}
|
||||
|
||||
return _internal;
|
||||
}
|
||||
}
|
||||
internal static void Shutdown()
|
||||
{
|
||||
_internal = null;
|
||||
SetInterface( server, new ISteamUserStats( server ) );
|
||||
InstallEvents();
|
||||
RequestCurrentStats();
|
||||
}
|
||||
|
||||
public static bool StatsRecieved { get; internal set; }
|
||||
|
||||
internal static void InstallEvents()
|
||||
{
|
||||
UserStatsReceived_t.Install( x =>
|
||||
Dispatch.Install<UserStatsReceived_t>( x =>
|
||||
{
|
||||
if ( x.SteamIDUser == SteamClient.SteamId )
|
||||
StatsRecieved = true;
|
||||
@@ -44,10 +30,10 @@ namespace Steamworks
|
||||
OnUserStatsReceived?.Invoke( x.SteamIDUser, x.Result );
|
||||
} );
|
||||
|
||||
UserStatsStored_t.Install( x => OnUserStatsStored?.Invoke( x.Result ) );
|
||||
UserAchievementStored_t.Install( x => OnAchievementProgress?.Invoke( new Achievement( x.AchievementNameUTF8() ), (int) x.CurProgress, (int)x.MaxProgress ) );
|
||||
UserStatsUnloaded_t.Install( x => OnUserStatsUnloaded?.Invoke( x.SteamIDUser ) );
|
||||
UserAchievementIconFetched_t.Install( x => OnAchievementIconFetched?.Invoke( x.AchievementNameUTF8(), x.IconHandle ) );
|
||||
Dispatch.Install<UserStatsStored_t>( x => OnUserStatsStored?.Invoke( x.Result ) );
|
||||
Dispatch.Install<UserAchievementStored_t>( x => OnAchievementProgress?.Invoke( new Achievement( x.AchievementNameUTF8() ), (int) x.CurProgress, (int)x.MaxProgress ) );
|
||||
Dispatch.Install<UserStatsUnloaded_t>( x => OnUserStatsUnloaded?.Invoke( x.SteamIDUser ) );
|
||||
Dispatch.Install<UserAchievementIconFetched_t>( x => OnAchievementIconFetched?.Invoke( x.AchievementNameUTF8(), x.IconHandle ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +136,22 @@ namespace Steamworks
|
||||
return Internal.RequestCurrentStats();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously fetches global stats data, which is available for stats marked as
|
||||
/// "aggregated" in the App Admin panel of the Steamworks website.
|
||||
/// You must have called RequestCurrentStats and it needs to return successfully via
|
||||
/// its callback prior to calling this.
|
||||
/// </summary>
|
||||
/// <param name="days">How many days of day-by-day history to retrieve in addition to the overall totals. The limit is 60.</param>
|
||||
/// <returns>OK indicates success, InvalidState means you need to call RequestCurrentStats first, Fail means the remote call failed</returns>
|
||||
public static async Task<Result> RequestGlobalStatsAsync( int days )
|
||||
{
|
||||
var result = await SteamUserStats.Internal.RequestGlobalStats( days );
|
||||
if ( !result.HasValue ) return Result.Fail;
|
||||
return result.Value.Result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets a leaderboard by name, it will create it if it's not yet created.
|
||||
/// Leaderboards created with this function will not automatically show up in the Steam Community.
|
||||
@@ -209,7 +211,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public static bool SetStat( string name, int value )
|
||||
{
|
||||
return Internal.SetStat1( name, value );
|
||||
return Internal.SetStat( name, value );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -218,7 +220,7 @@ namespace Steamworks
|
||||
/// </summary>
|
||||
public static bool SetStat( string name, float value )
|
||||
{
|
||||
return Internal.SetStat2( name, value );
|
||||
return Internal.SetStat( name, value );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -227,7 +229,7 @@ namespace Steamworks
|
||||
public static int GetStatInt( string name )
|
||||
{
|
||||
int data = 0;
|
||||
Internal.GetStat1( name, ref data );
|
||||
Internal.GetStat( name, ref data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -237,7 +239,7 @@ namespace Steamworks
|
||||
public static float GetStatFloat( string name )
|
||||
{
|
||||
float data = 0;
|
||||
Internal.GetStat2( name, ref data );
|
||||
Internal.GetStat( name, ref data );
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user