예제 #1
0
            unsafe void RunInternal()
            {
                string queryType = "";

                if (FileId.Count != 0)
                {
                    var fileArray = FileId.Select(x => (SteamNative.PublishedFileId_t)x).ToArray();
                    _resultsRemain = fileArray.Length;

                    Handle    = workshop.ugc.CreateQueryUGCDetailsRequest(fileArray);
                    queryType = "DetailsRequest";
                }
                else if (UserId.HasValue)
                {
                    uint accountId = (uint)(UserId.Value & 0xFFFFFFFFul);
                    Handle    = workshop.ugc.CreateQueryUserUGCRequest(accountId, (SteamNative.UserUGCList)(int) UserQueryType, (SteamNative.UGCMatchingUGCType)(int) QueryType, SteamNative.UserUGCListSortOrder.LastUpdatedDesc, UploaderAppId, AppId, (uint)_resultPage + 1);
                    queryType = "UserRequest";
                }
                else
                {
                    Handle    = workshop.ugc.CreateQueryAllUGCRequest((SteamNative.UGCQuery)(int) Order, (SteamNative.UGCMatchingUGCType)(int) QueryType, UploaderAppId, AppId, (uint)_resultPage + 1);
                    queryType = "AllRequest";
                }

                if (Handle == 0xfffffffffffffffful)
                {
                    throw new Exception("Steam UGC " + queryType + " Query Handle invalid!");
                }

                if (!string.IsNullOrEmpty(SearchText))
                {
                    workshop.ugc.SetSearchText(Handle, SearchText);
                }

                foreach (var tag in RequireTags)
                {
                    workshop.ugc.AddRequiredTag(Handle, tag);
                }

                if (RequireTags.Count > 0)
                {
                    workshop.ugc.SetMatchAnyTag(Handle, !RequireAllTags);
                }

                if (RankedByTrendDays > 0)
                {
                    workshop.ugc.SetRankedByTrendDays(Handle, (uint)RankedByTrendDays);
                }

                foreach (var tag in ExcludeTags)
                {
                    workshop.ugc.AddExcludedTag(Handle, tag);
                }

                Callback = workshop.ugc.SendQueryUGCRequest(Handle, ResultCallback);
            }
            unsafe void RunInternal()
            {
                if (FileId.Count != 0)
                {
                    var fileArray = FileId.Select(x => (SteamNative.PublishedFileId_t)x).ToArray();
                    _resultsRemain = fileArray.Length;

                    Handle = workshop.ugc.CreateQueryUGCDetailsRequest(fileArray);
                }
                else if (UserId.HasValue)
                {
                    uint accountId = (uint)(UserId.Value & 0xFFFFFFFFul);
                    Handle = workshop.ugc.CreateQueryUserUGCRequest(accountId, (SteamNative.UserUGCList)(int) UserQueryType, (SteamNative.UGCMatchingUGCType)(int) QueryType, SteamNative.UserUGCListSortOrder.LastUpdatedDesc, UploaderAppId, AppId, (uint)_resultPage + 1);
                }
                else
                {
                    Handle = workshop.ugc.CreateQueryAllUGCRequest((SteamNative.UGCQuery)(int) Order, (SteamNative.UGCMatchingUGCType)(int) QueryType, UploaderAppId, AppId, (uint)_resultPage + 1);
                }

                if (!string.IsNullOrEmpty(SearchText))
                {
                    workshop.ugc.SetSearchText(Handle, SearchText);
                }

                foreach (var tag in RequireTags)
                {
                    workshop.ugc.AddRequiredTag(Handle, tag);
                }

                if (RequireTags.Count > 0)
                {
                    workshop.ugc.SetMatchAnyTag(Handle, !RequireAllTags);
                }

                foreach (var tag in ExcludeTags)
                {
                    workshop.ugc.AddExcludedTag(Handle, tag);
                }

                Callback = workshop.ugc.SendQueryUGCRequest(Handle, OnResult);
                //  workshop.steamworks.AddCallResult( Callback );
            }
 internal void RegisterCallbackHandle(SteamNative.CallbackHandle handle)
 {
     CallbackHandles.Add(handle);
 }
예제 #4
0
            void ResultCallback(SteamNative.SteamUGCQueryCompleted_t data, bool bFailed)
            {
                if (bFailed)
                {
                    throw new System.Exception("Steam UGC Query failed: " + data.Result.ToString());
                }

                var gotFiles = 0;

                for (int i = 0; i < data.NumResultsReturned; i++)
                {
                    if (_resultSkip > 0)
                    {
                        _resultSkip--;
                        continue;
                    }

                    SteamNative.SteamUGCDetails_t details = new SteamNative.SteamUGCDetails_t();
                    if (!workshop.ugc.GetQueryUGCResult(data.Handle, (uint)i, ref details))
                    {
                        continue;
                    }

                    // We already have this file, so skip it
                    if (_results.Any(x => x.Id == details.PublishedFileId))
                    {
                        continue;
                    }

                    var item = Item.From(details, workshop);

                    item.SubscriptionCount = GetStat(data.Handle, i, ItemStatistic.NumSubscriptions);
                    item.FavouriteCount    = GetStat(data.Handle, i, ItemStatistic.NumFavorites);
                    item.FollowerCount     = GetStat(data.Handle, i, ItemStatistic.NumFollowers);
                    item.WebsiteViews      = GetStat(data.Handle, i, ItemStatistic.NumUniqueWebsiteViews);
                    item.ReportScore       = GetStat(data.Handle, i, ItemStatistic.ReportScore);

                    string url = null;
                    if (workshop.ugc.GetQueryUGCPreviewURL(data.Handle, (uint)i, out url))
                    {
                        item.PreviewImageUrl = url;
                    }

                    _results.Add(item);

                    _resultsRemain--;
                    gotFiles++;

                    if (_resultsRemain <= 0)
                    {
                        break;
                    }
                }

                TotalResults = TotalResults > data.TotalMatchingResults ? TotalResults : (int)data.TotalMatchingResults;

                Callback.Dispose();
                Callback = null;

                _resultPage++;

                if (_resultsRemain > 0 && gotFiles > 0)
                {
                    RunInternal();
                }
                else
                {
                    Items = _results.ToArray();

                    if (OnResult != null)
                    {
                        OnResult(this);
                    }
                }
            }