mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
auto wood
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user