コード例 #1
0
ファイル: ExFlyToTag.cs プロジェクト: MGramolini/ExBuddy
		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)
			{
				await ForceLand();
			}

			isDone = true;
			return true;
		}
コード例 #2
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);
        }
コード例 #3
0
ファイル: FlightPathTo.cs プロジェクト: Junified/ExBuddy
		public async Task<bool> Fly()
		{
			FlightPath flightPath = new StraightOrParabolicFlightPath(Me.Location, Target, this);

			var distance = flightPath.Distance;

			if (distance < Radius)
			{
				Logger.Info("Already in range -> Start: {0}, End: {1}", flightPath.Start, flightPath.End);
				isDone = true;
				return true;
			}

			StatusText = "Generating Path";

			FlightPath path;
			if (FlightPath.Paths.TryGetValue(flightPath.Key, out path))
			{
				flightPath = path;
				Logger.Info("Using existing FlightPath {0} from {1} to {2}", flightPath.Key, flightPath.Start, flightPath.End);
			}
			else
			{
				Logger.Info("Building new FlightPath {0} from {1} to {2}", 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.Verbose("Deviating from course to waypoint: {0}", flightPath.Current);
					}
					else
					{
						Logger.Verbose("Moving to waypoint: {0}", flightPath.Current);
					}

					await MoveToWithinRadius(flightPath.Current, Radius);
				}
				while (flightPath.Next());

				flightPath.Reset();
			}
			else
			{
				Logger.Error("No viable path computed for {0}.", Target);
			}

			if (ForceLanding)
			{
				await ForceLand();
			}

			isDone = true;
			return true;
		}