private static void FinishedTotalQuery(object sender) { WorkshopQueryAll workshopQueryAll = sender as WorkshopQueryAll; if (workshopQueryAll.numResultsTotal <= 0U) { return; } int num = Rando.Int((int)(workshopQueryAll.numResultsTotal / 50U)) + 1; if (RandomLevelDownloader.numSinceLowRating > 3) { RandomLevelDownloader.numSinceLowRating = 0; } else { num %= 10; } RandomLevelDownloader._orderMode = RandomLevelDownloader.numSinceLowRating != 2 ? WorkshopQueryFilterOrder.RankedByVote : WorkshopQueryFilterOrder.RankedByTrend; if (num == 0) { num = 1; } ++RandomLevelDownloader.numSinceLowRating; WorkshopQueryAll queryAll = Steam.CreateQueryAll(RandomLevelDownloader._orderMode, WorkshopType.Items); queryAll.requiredTags.Add("Deathmatch"); queryAll.ResultFetched += new WorkshopQueryResultFetched(RandomLevelDownloader.Fetched); queryAll.page = (uint)num; queryAll.justOnePage = true; queryAll.Request(); }
public static void Update() { if (!Steam.IsInitialized() || !Network.isServer || TeamSelect2.GetSettingInt("workshopmaps") <= 0) { return; } if (RandomLevelDownloader._downloading != null) { if (!RandomLevelDownloader._downloading.finishedProcessing) { return; } if (RandomLevelDownloader._downloading.downloadResult == SteamResult.OK) { RandomLevelDownloader.SearchDirLevels(RandomLevelDownloader._downloading.path, LevelLocation.Workshop); } RandomLevelDownloader._downloading = (WorkshopItem)null; } else { if (RandomLevelDownloader._currentQuery != null || RandomLevelDownloader._readyLevels.Count == RandomLevelDownloader.numToHaveReady) { return; } RandomLevelDownloader._toFetchIndex = -1; RandomLevelDownloader._numFetch = 0; RandomLevelDownloader._currentQuery = Steam.CreateQueryAll(RandomLevelDownloader._orderMode, WorkshopType.Items); RandomLevelDownloader._currentQuery.requiredTags.Add("Deathmatch"); RandomLevelDownloader._currentQuery.QueryFinished += new WorkshopQueryFinished(RandomLevelDownloader.FinishedTotalQuery); RandomLevelDownloader._currentQuery.fetchedData = WorkshopQueryData.TotalOnly; RandomLevelDownloader._currentQuery.Request(); DevConsole.Log(DCSection.Steam, "Querying for random levels."); } }
private static void Fetched(object sender, WorkshopQueryResult result) { if (RandomLevelDownloader._toFetchIndex == -1) { RandomLevelDownloader._toFetchIndex = Rando.Int((int)(sender as WorkshopQueryAll).numResultsFetched); } if (RandomLevelDownloader._toFetchIndex == RandomLevelDownloader._numFetch && Steam.DownloadWorkshopItem(result.details.publishedFile)) { RandomLevelDownloader._downloading = result.details.publishedFile; } RandomLevelDownloader._currentQuery = (WorkshopQueryAll)null; ++RandomLevelDownloader._numFetch; }