示例#1
0
        protected override async Task <bool> Main()
        {
            FlightPath flightPath = new StraightOrParabolicFlightPath(ExProfileBehavior.Me.Location, Target, this);

            var distance = flightPath.Distance;

            if (distance < Radius)
            {
                Logger.Info(Localization.Localization.ExFlyTo_Distance, flightPath.Start, flightPath.End);
                isDone = true;
                return(true);
            }

            StatusText = Localization.Localization.ExFlyTo_GenPath;

            FlightPath path;

            if (FlightPath.Paths.TryGetValue(flightPath.Key, out path))
            {
                flightPath = path;
                Logger.Info(Localization.Localization.ExFlyTo_ExsistingPath, flightPath.Key, flightPath.Start, flightPath.End);
            }
            else
            {
                Logger.Info(Localization.Localization.ExFlyTo_NewPath, flightPath.Key, flightPath.Start, flightPath.End);

                if (await flightPath.BuildPath())
                {
                    FlightPath.Paths[flightPath.Key] = flightPath;
                }
            }

            if (flightPath.Count > 0)
            {
                StatusText = "Target: " + Target;
                do
                {
                    if (flightPath.Current.IsDeviation)
                    {
                        Logger.Info(Localization.Localization.ExFlyTo_Deviating, flightPath.Current);
                    }
                    else
                    {
                        Logger.Verbose(Localization.Localization.ExFlyTo_MoveToWaypoint, flightPath.Current);
                        if (!ExBuddySettings.Instance.VerboseLogging &&
                            (flightPath.Index % 5 == 0 || flightPath.Index == flightPath.Count - 1))
                        {
                            Logger.Info(Localization.Localization.ExFlyTo_MoveToWaypoint2, flightPath.Index + 1, flightPath.Current);
                        }
                    }

                    // Last
                    if (RandomFinalSpot && flightPath.Index == flightPath.Count - 1)
                    {
                        Vector3 current = flightPath.Current;
                        current = current.AddRandomDirection(FinalSpotRadius, SphereType.TopHalf);

                        await MoveToWithinRadius(current);
                    }
                    else
                    {
                        await MoveToWithinRadius(flightPath.Current);
                    }
                } while (flightPath.Next());

                flightPath.Reset();
            }
            else
            {
                Logger.Error(Localization.Localization.ExFlyTo_NoViablePath, Target);
            }

            if (ForceLanding
#if !RB_CN
                && !MovementManager.IsDiving
#endif
                )
            {
                await ForceLand();
            }

            isDone = true;
            return(true);
        }