Пример #1
0
        private static async Task <Dictionary <FateData, float> > GetFateDistances()
        {
            if (!MovementSettings.Instance.TeleportIfQuicker || !MovementSettings.Instance.ConsiderAetheryteFateDistances || WorldManager.CanFly)
            {
                return(await OracleFateManager.GetActiveFateDistances());
            }

            Logger.SendDebugLog("Taking into account the distance to a FATE if we teleport to it.");
            var fateDistances = await OracleFateManager.GetActiveFateDistances();

            var fateDistancesFromAetherytes = new List <Dictionary <FateData, float> >();

            foreach (var aetheryte in
                     OracleFateManager.GetAetheryteIdsForZone(WorldManager.ZoneId).Where(item => WorldManager.KnownAetheryteIds.Contains(item.Item1)))
            {
                fateDistancesFromAetherytes.Add(await OracleFateManager.GetActiveFateDistances(aetheryte.Item2));
            }

            foreach (var fateDistance in await OracleFateManager.GetActiveFateDistances())
            {
                if (fateDistance.Key.Progress < MovementSettings.Instance.FateProgressTeleportLimit)
                {
                    continue;
                }

                Logger.SendDebugLog("Ignoring teleport distance for " + fateDistance.Key.Name + ", its progress (" + fateDistance.Key.Progress
                                    + "%) equals or exceeds the limit (" + MovementSettings.Instance.FateProgressTeleportLimit + "%).");
            }

            foreach (var aetheryteDistanceDict in fateDistancesFromAetherytes)
            {
                foreach (var fateDistance in aetheryteDistanceDict)
                {
                    float currentDistance;
                    if (!fateDistances.TryGetValue(fateDistance.Key, out currentDistance))
                    {
                        continue;
                    }

                    if (fateDistance.Key.Progress >= MovementSettings.Instance.FateProgressTeleportLimit)
                    {
                        continue;
                    }

                    // Add the minimum distance delta to ensure we don't teleport if distance saved is under that amount.
                    if (fateDistance.Value + MovementSettings.Instance.MinDistanceToTeleport >= currentDistance)
                    {
                        continue;
                    }

                    fateDistances.Remove(fateDistance.Key);
                    fateDistances.Add(fateDistance.Key, fateDistance.Value);
                }
            }

            return(fateDistances);
        }