diff --git a/Facepunch.Steamworks/Client/Leaderboard.cs b/Facepunch.Steamworks/Client/Leaderboard.cs index db4fce7..18e45a0 100644 --- a/Facepunch.Steamworks/Client/Leaderboard.cs +++ b/Facepunch.Steamworks/Client/Leaderboard.cs @@ -161,6 +161,32 @@ public bool AddScore( bool onlyIfBeatsOldScore, int score, int[] subscores = nul return true; } + public delegate void AttachRemoteFileCallback( bool success ); + + public bool AttachRemoteFile( RemoteFile file, AttachRemoteFileCallback callback = null ) + { + if ( file.IsShared ) + { + client.native.userstats.AttachLeaderboardUGC( BoardId, file.UGCHandle, ( result, error ) => + { + callback?.Invoke( !error && result.Result == Result.OK ); + } ); + return true; + } + + file.Share( success => + { + if ( !success || !file.IsShared ) + { + callback?.Invoke( false ); + return; + } + + AttachRemoteFile( file, callback ); + } ); + return true; + } + /// /// Fetch a subset of scores. The scores end up in Results. /// diff --git a/Facepunch.Steamworks/Client/RemoteStorage.cs b/Facepunch.Steamworks/Client/RemoteStorage.cs index ca762d7..2a5a19f 100644 --- a/Facepunch.Steamworks/Client/RemoteStorage.cs +++ b/Facepunch.Steamworks/Client/RemoteStorage.cs @@ -113,6 +113,9 @@ public class RemoteFile private ulong _ownerId; public bool Exists { get; internal set; } + public bool IsShared { get { return _handle.Value != 0; } } + + internal UGCHandle_t UGCHandle { get { return _handle; } } public string FileName {