Include "Success" field in LeaderboardUpdate struct

This commit is contained in:
James King 2022-03-18 19:55:53 +01:00
parent 9f0de903d4
commit 12902b416e
2 changed files with 14 additions and 15 deletions

View File

@ -32,7 +32,7 @@ namespace Steamworks.Data
var r = await SteamUserStats.Internal.UploadLeaderboardScore( Id, LeaderboardUploadScoreMethod.ForceUpdate, score, details, details.Length );
if ( !r.HasValue ) return null;
return LeaderboardUpdate.From( r.Value );
return new LeaderboardUpdate( r.Value );
}
/// <summary>
@ -45,7 +45,7 @@ namespace Steamworks.Data
var r = await SteamUserStats.Internal.UploadLeaderboardScore( Id, LeaderboardUploadScoreMethod.KeepBest, score, details, details.Length );
if ( !r.HasValue ) return null;
return LeaderboardUpdate.From( r.Value );
return new LeaderboardUpdate( r.Value );
}
/// <summary>

View File

@ -4,19 +4,18 @@ namespace Steamworks.Data
{
public struct LeaderboardUpdate
{
public int Score;
public bool Changed;
public int NewGlobalRank;
public int OldGlobalRank;
private readonly LeaderboardScoreUploaded_t _internal;
public bool Success => _internal.Success != 0;
public int Score => _internal.Score;
public bool Changed => _internal.ScoreChanged != 0;
public int NewGlobalRank => _internal.GlobalRankNew;
public int OldGlobalRank => _internal.GlobalRankPrevious;
public int RankChange => NewGlobalRank - OldGlobalRank;
internal static LeaderboardUpdate From( LeaderboardScoreUploaded_t e ) =>
new LeaderboardUpdate
{
Score = e.Score,
Changed = e.ScoreChanged == 1,
NewGlobalRank = e.GlobalRankNew,
OldGlobalRank = e.GlobalRankPrevious
};
internal LeaderboardUpdate( LeaderboardScoreUploaded_t result )
{
_internal = result;
}
}
}
}