auto wood

This commit is contained in:
huiyadanli
2023-11-25 22:30:18 +08:00
parent 5068f4a7f7
commit 408e372481
18 changed files with 434 additions and 50 deletions

View File

@@ -26,6 +26,31 @@ public class TaskControl
Thread.Sleep(millisecondsTimeout);
}
public static void Sleep(int millisecondsTimeout, CancellationTokenSource cts)
{
if (cts.IsCancellationRequested)
{
throw new NormalEndException("取消自动伐木任务");
}
Retry.Do(() =>
{
if (cts.IsCancellationRequested)
{
throw new NormalEndException("取消自动伐木任务");
}
if (!SystemControl.IsGenshinImpactActiveByProcess())
{
Logger.LogInformation("当前获取焦点的窗口不是原神,暂停");
throw new RetryException("当前获取焦点的窗口不是原神");
}
}, TimeSpan.FromSeconds(1), 100);
Thread.Sleep(millisecondsTimeout);
if (cts.IsCancellationRequested)
{
throw new NormalEndException("取消自动伐木任务");
}
}
public static Bitmap CaptureGameBitmap(IGameCapture? gameCapture)
{
var bitmap = gameCapture?.Capture();
@@ -47,4 +72,10 @@ public class TaskControl
return bitmap;
}
public static CaptureContent CaptureToContent(IGameCapture? gameCapture)
{
var bitmap = CaptureGameBitmap(gameCapture);
return new CaptureContent(bitmap, 0, 0, null);
}
}