From 966ad90630663d249ec894e01e096f4e310f3e18 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Wed, 8 May 2019 09:40:28 +0100 Subject: [PATCH] Added SteamUGC.FetchItem --- Facepunch.Steamworks/SteamUgc.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs index d430794..17f24c2 100644 --- a/Facepunch.Steamworks/SteamUgc.cs +++ b/Facepunch.Steamworks/SteamUgc.cs @@ -44,5 +44,24 @@ namespace Steamworks { return Internal.DownloadItem( fileId, highPriority ); } + + /// + /// Utility function to fetch a single item. Internally this uses Ugc.FileQuery - + /// which you can use to query multiple items if you need to. + /// + public static async Task FetchItem( PublishedFileId fileId ) + { + var result = await new Ugc.FileQuery( fileId ) + .GetPageAsync( 1 ); + + if ( !result.HasValue || result.Value.ResultCount != 1 ) + return null; + + var item = result.Value.Entries.First(); + + result.Value.Dispose(); + + return item; + } } } \ No newline at end of file