/// <summary> /// 开始服务 /// </summary> public static async Task Start() { //只在榜单服运行 if (!Host.Role.HasRole(ServerRole.Rank)) { Logger.LogDebug("Skip"); return; } Logger.LogDebug("Start"); PKRankPool = new RankPool <int, TRankPKItem>(PKRankCapacity, deleteIfFull: true); COOPRankPool = new RankPool <string, TRankCOOPItem>(COOPRankCapacity, deleteIfFull: true); //PK榜单 await TRankPKItem.Cache.LoadAllEntitiesAsync(); PKRankPool.Load(TRankPKItem.Cache, CheckPKItemAvailable, true); Logger.LogDebug($"Load TRankPKItem Count[{TRankPKItem.Cache.Entities.Count()}]"); Logger.LogDebug($"Create PKRankPool Count[{PKRankPool.Count}]"); var pkFirst = PKRankPool.First; if (pkFirst != null) { Logger.LogDebug($"PKRankPool.First Score[{pkFirst.Score}]"); } var pkLast = PKRankPool.Last; if (pkLast != null) { Logger.LogDebug($"PKRankPool.Last Score[{pkLast.Score}]"); } //COOP榜单 await TRankCOOPItem.Cache.LoadAllEntitiesAsync(); COOPRankPool.Load(TRankCOOPItem.Cache, CheckCOOPItemAvailable, true); Logger.LogDebug($"Load TRankCOOPItem Count[{TRankCOOPItem.Cache.Entities.Count()}]"); Logger.LogDebug($"Create COOPRankPool Count[{COOPRankPool.Count}]"); var coopFirst = COOPRankPool.First; if (coopFirst != null) { Logger.LogDebug($"COOPRankPool.First Round[{coopFirst.Round}]"); } var coopLast = COOPRankPool.Last; if (coopLast != null) { Logger.LogDebug($"COOPRankPool.Last Round[{coopLast.Round}]"); } }
/// <summary> /// 开始服务 /// </summary> public static async Task Start() { //只在逻辑服运行 if (!Host.Role.HasRole(ServerRole.Logic)) { Logger.LogDebug("Skip"); return; } Logger.LogDebug("Start"); //初始化PK榜单 PKRankPool = new RankPool <int, TRankPKItem>(RankCenterService.PKRankCapacity, false); Logger.LogDebug($"Create PKRankPool"); //初始化COOP榜单 COOPRankPool = new RankPool <string, TRankCOOPItem>(RankCenterService.COOPRankCapacity, false); Logger.LogDebug($"Create COOPRankPool"); //统一等待45秒后, 每个逻辑服依次间隔2秒, 尝试重新加载所有榜单 await Task.Delay((45 + (Host.ServerId * 2)) * 1000).ContinueWith(TryReloadAllRank); }