Skip to content

Yukinii/Async-Await-Steamworks.NET

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FOR THE ORIGINAL CODE GO TO STEAMWORKS.NET

#Task Async/Await Steamworks.NET Wrapper

Getting Started
        private static SteamManager _Instance;
        public static SteamManager Instance => _Instance ?? new SteamManager();
        
        public SteamManager()
        {
            if (_Instance == null)
                _Instance = this;

            if (SteamAPI.RestartAppIfNecessary((AppId)432200))
                Environment.Exit(0);
            if (!SteamAPI.Init())
                Environment.Exit(0);
            
            SteamUGC.OnDownloadCompleted += DownloadCompleted;
            SteamUGC.OnItemInstalled += ItemInstalled;
        }

Notice the two events on the bottom? No more CallbackResult mess!

The Async/Await Part

Async/Await version:

        private async void ItemInstalled(ItemInstalled item)
        {
             var result = await SteamUGC.GetItemDetailsAsync(item.PublishedFileId);
             Console.WriteLine("Installed: "+result.Details.Title);
        }

versus...

        private void ItemInstalled(ItemInstalled_t param)
        {
            var call = SteamUGC.RequestUGCDetails(param.m_nPublishedFileId, 0);
            var detailRequestResult = new CallResult<SteamUGCRequestUGCDetailsResult_t>();
            detailRequestResult.Set(call, (result, isCached) =>
            {
                Console.WriteLine("Installed: " + result.m_details.m_rgchTitle);
            });
            //now hold the flow here somehow to return the data to a UI since the result will come in whenever..
        }
The Clean Part

No more '_t' class endings or other artifacts from automated code generation! Compare the following two screenshots to the two I took with this wrapper and you'll surely see why this wrapper is easier to use.

Steamworks.NET

Steamworks.NET Async/Await

About

Async/Await Steamworks for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%