public static async Task<bool> MoveTo(Vector3 destination, bool useMesh = true, uint mountId = 0, float radius = 2.0f, string name = null, Func<float, float, bool> stopCallback = null, bool dismountAtDestination = false) { // ReSharper disable once InconsistentNaming var distance3d = Core.Player.Location.Distance3D(destination); if (Actionmanager.CanMount == 0 && ((!Core.Player.IsMounted && distance3d >= CharacterSettings.Instance.MountDistance && CharacterSettings.Instance.UseMount) || !destination.IsGround())) { var ticks = 0; while (!Core.Player.IsMounted && ticks++ < 10 && ShouldContinue) { if (mountId > 0) { if (!await CommonTasks.MountUp(mountId)) { if (!await CommonTasks.MountUp(1)) { await CommonTasks.MountUp(45); } } } else { await CommonTasks.MountUp(); } await Coroutine.Yield(); } } await MoveToNoMount(destination, useMesh, radius, name, stopCallback); var dismountTicks = 0; while (dismountAtDestination && dismountTicks++ < 10 && Core.Player.IsMounted && ShouldContinue) { if (MovementManager.IsFlying) { if (Navigator.PlayerMover is FlightEnabledSlideMover) { Navigator.Stop(); } else { MovementManager.StartDescending(); } } else { Actionmanager.Dismount(); } await Coroutine.Wait(1000, () => !Core.Player.IsMounted); } if (dismountTicks >= 10) { Logging.Write(Colors.Red, "Failed to dismount after MoveTo task."); return false; } return true; }
public static async Task<bool> MoveTo( Vector3 destination, bool useMesh = true, uint mountId = 0, float radius = 2.0f, string name = null, Func<float, float, bool> stopCallback = null, bool dismountAtDestination = false) { // ReSharper disable once InconsistentNaming var distance3d = Core.Player.Location.Distance3D(destination); if (Actionmanager.CanMount == 0 && ((!Core.Player.IsMounted && distance3d >= CharacterSettings.Instance.MountDistance && CharacterSettings.Instance.UseMount) || !destination.IsGround())) { uint flightSpecificMountId = 0; if (mountId == 0) { mountId = CharacterSettings.Instance.MountId; if (mountId == uint.MaxValue) { var mount = Actionmanager.AvailableMounts.Shuffle().FirstOrDefault(); if (mount != null) { mountId = mount.Id; } } var playerMover = Navigator.PlayerMover as IFlightEnabledPlayerMover; if (playerMover != null) { flightSpecificMountId = (uint)playerMover.FlightMovementArgs.MountId; } } var ticks = 0; while (!Core.Player.IsMounted && ticks++ < 10 && ShouldContinue) { if (WorldManager.CanFly && flightSpecificMountId > 0) { await CommonTasks.MountUp(flightSpecificMountId); await Coroutine.Yield(); if (Core.Player.IsMounted) { break; } } if (mountId > 0) { if (!await CommonTasks.MountUp(mountId)) { if (!await CommonTasks.MountUp(1)) { await CommonTasks.MountUp(45); } } } else { await CommonTasks.MountUp(); } await Coroutine.Yield(); } } await MoveToNoMount(destination, useMesh, radius, name, stopCallback); var dismountTicks = 0; while (dismountAtDestination && dismountTicks++ < 100 && Core.Player.IsMounted && ShouldContinue) { if (MovementManager.IsFlying) { if (Navigator.PlayerMover is FlightEnabledSlideMover) { Navigator.Stop(); } else { MovementManager.StartDescending(); } } else { Actionmanager.Dismount(); } await Coroutine.Wait(100, () => !Core.Player.IsMounted); } if (dismountTicks > 100) { Logger.Instance.Error("Failed to dismount after MoveTo task."); return false; } return true; }
internal static bool ShouldFlyInternal(Vector3 destination) { return MovementManager.IsFlying || (Actionmanager.CanMount == 0 && ((destination.Distance3D(GameObjectManager.LocalPlayer.Location) >= CharacterSettings.Instance.MountDistance) || !destination.IsGround())); }