Ejemplo n.º 1
0
        public static async Task <bool> MoveToPointWithinNoMount(
            this Vector3 destination,
            float radius,
            string name = null)
        {
            var sprintDistance = Math.Min(20.0f, CharacterSettings.Instance.MountDistance);

            var moveResult = MoveResult.GeneratingPath;

            if (!MovementManager.IsFlying && !MovementManager.IsDiving)
            {
                destination = destination.AddRandomDirection2D(10.0f);
            }

            while (Behaviors.ShouldContinue && !moveResult.IsDoneMoving())
            {
                moveResult = Navigator.MoveTo(new MoveToParameters(destination));
                await Coroutine.Yield();

                var distance = Core.Player.Location.Distance3D(destination);
                if (distance > sprintDistance)
                {
                    await Sprint();
                }
            }

            Navigator.Stop();

            return(true);
        }
Ejemplo n.º 2
0
        public MoveResult MoveToRandomSpotWithin(Vector3 location, float radius, string destination = null)
        {
            if (generatingPath)
            {
                return(MoveResult.GeneratingPath);
            }

            if (!playerMover.CanFly || (!MovementManager.IsFlying && !playerMover.ShouldFlyTo(location)))
            {
                return(innerNavigator.MoveTo(location, destination));
            }

            var currentLocation = GameObjectManager.LocalPlayer.Location;

            if (location.DistanceSqr(currentLocation) > PathPrecisionSqr)
            {
                if (ShouldGeneratePath(location, radius))
                {
                    generatingPath       = true;
                    origin               = currentLocation;
                    requestedDestination = location;
                    finalDestination     = location.AddRandomDirection2D(radius);
                    pathGeneratorStopwatch.Restart();
                    logger.Info("Generating path on {0} from {1} to {2}", WorldManager.ZoneId, origin, finalDestination);
                    GeneratePath(origin, finalDestination).ContinueWith(HandlePathGenerationResult);
                    return(MoveResult.GeneratingPath);
                }

                if (CurrentPath.Count == 0)
                {
                    return(MoveResult.ReachedDestination);
                }

                return(MoveToNextHop(destination));
            }

            logger.Info("Navigation reached current destination. Within {0}", currentLocation.Distance(location));

            requestedDestination = Vector3.Zero;
            playerMover.MoveStop();
            CurrentPath.Reset();

            return(MoveResult.Done);
        }