コード例 #1
0
        private static async Task <bool> SelectChainFate()
        {
            if (!OracleFateManager.WaitingForChainFate())
            {
                return(false);
            }

            var chainId             = OracleFateManager.FateDatabase.GetFateFromId(OracleFateManager.PreviousFateId).ChainId;
            var chainOracleFateInfo = OracleFateManager.FateDatabase.GetFateFromId(chainId);

            if (chainFateTimer == null || !chainFateTimer.IsRunning)
            {
                chainFateTimer = Stopwatch.StartNew();
            }
            else if (chainFateTimer.Elapsed > TimeSpan.FromSeconds(FateSettings.Instance.ChainWaitTimeout))
            {
                Logger.SendLog("Timed out waiting for the next FATE in the chain to appear.");
                OracleFateManager.PreviousFateId = 0;
                chainFateTimer.Reset();
            }

            Logger.SendLog("Waiting for the follow up FATE: " + chainOracleFateInfo.Name + ".");
            var chainFateData = FateManager.ActiveFates.FirstOrDefault(result => result.Id == chainId);

            if (chainFateData == null)
            {
                return(false);
            }

            // Fix for FATEs that spawn instantly after the previous ends.
            if (chainFateData.Name.Equals(string.Empty))
            {
                Logger.SendLog("Selected FATE: " + chainOracleFateInfo.Name + ".");
            }
            else
            {
                Logger.SendLog("Selected FATE: " + chainFateData.Name + ".");
            }

            OracleFateManager.CurrentFateId = chainFateData.Id;
            Poi.Current = new Poi(chainFateData, PoiType.Fate);
            chainFateTimer.Reset();
            return(true);
        }