diff --git a/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs b/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs index 5b5e15d7..66058aac 100644 --- a/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs +++ b/BetterGenshinImpact/GameTask/AutoPathing/Handler/ActionFactory.cs @@ -15,7 +15,7 @@ public class ActionFactory return key switch { "nahida_collect" => new NahidaCollectHandler(), - "pick_around" => new PickAroundHandler(1), + "pick_around" => new PickAroundHandler(), "fight" => new AutoFightHandler(), "normal_attack" => new NormalAttackHandler(), "elemental_skill" => new ElementalSkillHandler(), diff --git a/BetterGenshinImpact/GameTask/AutoPathing/Handler/PickAroundHandler.cs b/BetterGenshinImpact/GameTask/AutoPathing/Handler/PickAroundHandler.cs index d0edc167..553108e4 100644 --- a/BetterGenshinImpact/GameTask/AutoPathing/Handler/PickAroundHandler.cs +++ b/BetterGenshinImpact/GameTask/AutoPathing/Handler/PickAroundHandler.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging; using System.Threading; using System.Threading.Tasks; using BetterGenshinImpact.GameTask.AutoPathing.Model; +using BetterGenshinImpact.Helpers; using Vanara.PInvoke; using static BetterGenshinImpact.GameTask.Common.TaskControl; @@ -13,15 +14,22 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler; /// /// 采集任务到达点位后执行拾取操作 /// -public class PickAroundHandler(int turns) : IActionHandler +public class PickAroundHandler() : IActionHandler { private CancellationToken _ct; + public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null) { this._ct = ct; Logger.LogInformation("执行 {Text}", "小范围内自动拾取"); double speed = 1.1; + int turns = 1; + if (waypointForTrack is { ActionParams: not null }) + { + turns = StringUtils.TryParseInt(waypointForTrack.ActionParams, 1); + } + // 无加成幼年为 1, 少年为 1.1, 成年为 1.2, 若有移速加成, 再乘以加成倍率. CircularMotionCalculator calculator = new CircularMotionCalculator(speed); double oldRadiusT = 0; @@ -45,6 +53,7 @@ public class PickAroundHandler(int turns) : IActionHandler Simulation.SendInput.Mouse.MiddleButtonClick(); await Delay((int)Math.Round(edgeT), _ct); } + Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_A); await Delay(200, _ct); } @@ -126,4 +135,4 @@ public class CircularMotionCalculator double endAngle = angle - _mixAngle + Math.Atan2(x, y) + Math.PI / 2; return (edgeT / Speed, smallRadiusT / Speed, endAngle); } -} +} \ No newline at end of file diff --git a/BetterGenshinImpact/Helpers/StringUtils.cs b/BetterGenshinImpact/Helpers/StringUtils.cs index 4b8d9127..cf31186d 100644 --- a/BetterGenshinImpact/Helpers/StringUtils.cs +++ b/BetterGenshinImpact/Helpers/StringUtils.cs @@ -82,6 +82,11 @@ public partial class StringUtils _ = int.TryParse(text, out int result); return result; } + + public static int TryParseInt(string text, int defaultValue) + { + return int.TryParse(text, out int result) ? result : defaultValue; + } public static int TryExtractPositiveInt(string text) {