Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b0746d2bd |
No files matched your search
@@ -19,17 +19,17 @@ public class AvatarClassifyGen
|
||||
// 读取基础图像
|
||||
// List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "*.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// 只用一个图像
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_HutaoCostumeWinter.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Iansan.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Chasca.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Olorun.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles2);
|
||||
List<string> sideImageFiles3 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Citlali.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles3);
|
||||
List<string> sideImageFiles4 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Lanyan.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles4);
|
||||
List<string> sideImageFiles5 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_XianglingCostumeWinter.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles5);
|
||||
List<string> sideImageFiles6 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Mavuika.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles6);
|
||||
// List<string> sideImageFiles3 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_NilouCostumeFairy.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles3);
|
||||
// List<string> sideImageFiles4 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Kachina.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles4);
|
||||
// List<string> sideImageFiles5 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Mualani.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles5);
|
||||
// List<string> sideImageFiles6 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Kinich.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles6);
|
||||
|
||||
// 生成训练集
|
||||
GenTo(sideImageFiles, Path.Combine(BaseDir, @"dateset\train"), 200);
|
||||
|
||||
@@ -27,17 +27,9 @@ public class AvatarClassifyTransparentGen
|
||||
// 读取基础图像
|
||||
// List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "*.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// 只用一个图像
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_HutaoCostumeWinter.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Iansan.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Chasca.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Olorun.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles2);
|
||||
List<string> sideImageFiles3 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Citlali.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles3);
|
||||
List<string> sideImageFiles4 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Lanyan.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles4);
|
||||
List<string> sideImageFiles5 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_XianglingCostumeWinter.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles5);
|
||||
List<string> sideImageFiles6 = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Mavuika.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
sideImageFiles.AddRange(sideImageFiles6);
|
||||
// 生成训练集
|
||||
GenTo(sideImageFiles, Path.Combine(BaseDir, @"dateset\train"), 200);
|
||||
// 生成测试集
|
||||
|
||||
@@ -61,7 +61,7 @@ internal class HsvTestWindow
|
||||
Cv2.CreateTrackbar("High S", _windowDetectionName, ref _highS, MaxValue, on_high_S_thresh_trackbar);
|
||||
Cv2.CreateTrackbar("Low V", _windowDetectionName, ref _lowV, MaxValue, on_low_V_thresh_trackbar);
|
||||
Cv2.CreateTrackbar("High V", _windowDetectionName, ref _highV, MaxValue, on_high_V_thresh_trackbar);
|
||||
var frame = Cv2.ImRead(@"E:\HuiTask\更好的原神\自动秘境\Q识别\拼图\2.png", ImreadModes.Color);
|
||||
var frame = Cv2.ImRead(@"E:\HuiTask\更好的原神\自动秘境\自动战斗\队伍识别\bsz1.png", ImreadModes.Color);
|
||||
Mat frameHsv = new Mat();
|
||||
// Convert from BGR to HSV colorspace
|
||||
Cv2.CvtColor(frame, frameHsv, ColorConversionCodes.BGR2HSV);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="NativeMethods.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.46-beta">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/CsWin32/main/src/Microsoft.Windows.CsWin32/settings.schema.json",
|
||||
"allowMarshaling": true,
|
||||
"useSafeHandles": false,
|
||||
"emitSingleFile": true,
|
||||
"public": true,
|
||||
"comInterop": {
|
||||
"useIntPtrForComOutPointers": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// D3D11
|
||||
CreateDirect3D11DeviceFromDXGIDevice
|
||||
CreateDirect3D11SurfaceFromDXGISurface
|
||||
|
||||
// GDI32
|
||||
BitBlt
|
||||
CreateCompatibleBitmap
|
||||
CreateCompatibleDC
|
||||
DeleteDC
|
||||
GetDeviceCaps
|
||||
SelectObject
|
||||
|
||||
// User32
|
||||
GetClientRect
|
||||
GetDC
|
||||
GetForegroundWindow
|
||||
GetSystemMetrics
|
||||
GetWindowDC
|
||||
GetWindowRect
|
||||
GetWindowThreadProcessId
|
||||
mouse_event
|
||||
PostMessage
|
||||
ReleaseDC
|
||||
EnumWindows
|
||||
GetWindowText
|
||||
IsWindowVisible
|
||||
GetWindowTextLength
|
||||
|
||||
// COM & WinRT
|
||||
D3D11CreateDevice
|
||||
ID3D11Device3
|
||||
IDirect3DDxgiInterfaceAccess
|
||||
|
||||
// Constants
|
||||
D3D11_SDK_VERSION
|
||||
DXGI_ERROR_UNSUPPORTED
|
||||
WM_LBUTTONDOWN
|
||||
WM_LBUTTONUP
|
||||
@@ -5,10 +5,18 @@ VisualStudioVersion = 17.6.33815.320
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterGenshinImpact", "BetterGenshinImpact\BetterGenshinImpact.csproj", "{75EC89E2-413D-4725-BCEA-AFAC57708F07}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vision.WindowCapture", "Vision.WindowCapture\Vision.WindowCapture.csproj", "{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterGenshinImpact.Win32", "BetterGenshinImpact.Win32\BetterGenshinImpact.Win32.csproj", "{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fischless.GameCapture", "Fischless.GameCapture\Fischless.GameCapture.csproj", "{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vision.WindowCapture.Test", "Vision.WindowCapture.Test\Vision.WindowCapture.Test.csproj", "{D35CB953-C666-4E57-9A9A-3AAE5BF78402}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fischless.HotkeyCapture", "Fischless.HotkeyCapture\Fischless.HotkeyCapture.csproj", "{08152E44-2564-46C5-B5B2-54DD43C01A79}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fischless.KeyboardCapture", "Fischless.KeyboardCapture\Fischless.KeyboardCapture.csproj", "{10A48327-7E58-4B51-B1FC-55506C703C8F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Deploy", "Deploy", "{458E1106-43A4-47E6-B11B-D243035D4C76}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicaSetup", "Build\MicaSetup\MicaSetup.csproj", "{AB85DA23-EB8F-4FBF-A7FA-35CE05B23C15}"
|
||||
@@ -19,6 +27,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterGenshinImpact.Test",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Fischless.WindowsInput", "Fischless.WindowsInput\Fischless.WindowsInput.csproj", "{9D00BC7A-9280-4AC9-8951-4502EDB71B76}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Build\Updater\Updater.csproj", "{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -35,6 +45,22 @@ Global
|
||||
{75EC89E2-413D-4725-BCEA-AFAC57708F07}.Release|Any CPU.Build.0 = Release|x64
|
||||
{75EC89E2-413D-4725-BCEA-AFAC57708F07}.Release|x64.ActiveCfg = Release|x64
|
||||
{75EC89E2-413D-4725-BCEA-AFAC57708F07}.Release|x64.Build.0 = Release|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Debug|x64.Build.0 = Debug|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Release|Any CPU.Build.0 = Release|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Release|x64.ActiveCfg = Release|x64
|
||||
{C9080C1D-1B26-46CB-A494-A5E7FE3FCEBA}.Release|x64.Build.0 = Release|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Debug|x64.Build.0 = Debug|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Release|Any CPU.Build.0 = Release|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Release|x64.ActiveCfg = Release|x64
|
||||
{75F4541B-9624-4AFB-BAEA-3EAFD3300EE1}.Release|x64.Build.0 = Release|x64
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -43,6 +69,14 @@ Global
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Release|Any CPU.Build.0 = Release|x64
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Release|x64.ActiveCfg = Release|x64
|
||||
{6B0A3D96-D88D-48DD-8112-4CD5BA5D27CE}.Release|x64.Build.0 = Release|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Debug|x64.Build.0 = Debug|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Release|Any CPU.Build.0 = Release|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Release|x64.ActiveCfg = Release|x64
|
||||
{D35CB953-C666-4E57-9A9A-3AAE5BF78402}.Release|x64.Build.0 = Release|x64
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -51,6 +85,14 @@ Global
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Release|Any CPU.Build.0 = Release|x64
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Release|x64.ActiveCfg = Release|x64
|
||||
{08152E44-2564-46C5-B5B2-54DD43C01A79}.Release|x64.Build.0 = Release|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Debug|x64.Build.0 = Debug|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Release|Any CPU.Build.0 = Release|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Release|x64.ActiveCfg = Release|x64
|
||||
{10A48327-7E58-4B51-B1FC-55506C703C8F}.Release|x64.Build.0 = Release|x64
|
||||
{AB85DA23-EB8F-4FBF-A7FA-35CE05B23C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AB85DA23-EB8F-4FBF-A7FA-35CE05B23C15}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AB85DA23-EB8F-4FBF-A7FA-35CE05B23C15}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -83,6 +125,14 @@ Global
|
||||
{9D00BC7A-9280-4AC9-8951-4502EDB71B76}.Release|Any CPU.Build.0 = Release|x64
|
||||
{9D00BC7A-9280-4AC9-8951-4502EDB71B76}.Release|x64.ActiveCfg = Release|x64
|
||||
{9D00BC7A-9280-4AC9-8951-4502EDB71B76}.Release|x64.Build.0 = Release|x64
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -90,6 +140,7 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{AB85DA23-EB8F-4FBF-A7FA-35CE05B23C15} = {458E1106-43A4-47E6-B11B-D243035D4C76}
|
||||
{673344BC-B860-44AE-AD88-D33465BDE25B} = {458E1106-43A4-47E6-B11B-D243035D4C76}
|
||||
{F18CF5A3-A83C-4CC6-8150-D3C40EC3140F} = {458E1106-43A4-47E6-B11B-D243035D4C76}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {352D8B78-9DE3-4E58-985F-FADD22594DB4}
|
||||
|
||||
@@ -10,8 +10,8 @@ using BetterGenshinImpact.View;
|
||||
using BetterGenshinImpact.View.Pages;
|
||||
using BetterGenshinImpact.ViewModel;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using BetterGenshinImpact.ViewModel.Pages.View;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
@@ -22,9 +22,6 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using BetterGenshinImpact.View.Pages.View;
|
||||
using BetterGenshinImpact.ViewModel.Pages.OneDragon;
|
||||
using BetterGenshinImpact.ViewModel.Pages.View;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
@@ -102,7 +99,6 @@ public partial class App : Application
|
||||
services.AddView<OneDragonFlowPage, OneDragonFlowViewModel>();
|
||||
services.AddSingleton<PathingConfigViewModel>();
|
||||
// services.AddView<PathingConfigView, PathingConfigViewModel>();
|
||||
services.AddView<KeyBindingsSettingsPage, KeyBindingsSettingsPageViewModel>();
|
||||
|
||||
// 一条龙 ViewModels
|
||||
// services.AddSingleton<CraftViewModel>();
|
||||
@@ -185,8 +181,6 @@ public partial class App : Application
|
||||
protected override async void OnExit(ExitEventArgs e)
|
||||
{
|
||||
base.OnExit(e);
|
||||
|
||||
TempManager.CleanUp();
|
||||
|
||||
await _host.StopAsync();
|
||||
_host.Dispose();
|
||||
|
||||
|
Before Width: | Height: | Size: 288 KiB |
|
After Width: | Height: | Size: 136 KiB |
@@ -10,7 +10,7 @@
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<AssemblyVersion>0.42.0</AssemblyVersion>
|
||||
<AssemblyVersion>0.37.3</AssemblyVersion>
|
||||
<Platforms>x64</Platforms>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
@@ -42,12 +42,12 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="Downloader" Version="3.3.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime.DirectML" Version="1.18.1" />
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.18.1" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2592.51" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="OpenCvSharp4.WpfExtensions" Version="4.8.0.20230708" />
|
||||
@@ -129,9 +129,6 @@
|
||||
<None Update="GameTask\AutoWood\Assets\1920x1080\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\AutoMusicGame\Assets\1920x1080\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\GameLoading\Assets\1920x1080\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -147,8 +144,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="GameTask\Common\Element\Assets\Json\" />
|
||||
<Folder Include="GameTask\OneDragon\" />
|
||||
<Folder Include="Service\Notification\Builder\" />
|
||||
<Folder Include="User\AutoPathing\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -7,17 +7,13 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
using BetterGenshinImpact.GameTask.AutoPick;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
using BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
using BetterGenshinImpact.GameTask.QuickTeleport;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Fischless.GameCapture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
@@ -71,15 +67,6 @@ public partial class AllConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _inferenceDevice = "CPU";
|
||||
|
||||
[ObservableProperty]
|
||||
private List<ValueTuple<string, int, string, string>> _nextScheduledTask = [];
|
||||
|
||||
/// <summary>
|
||||
/// 一条龙选中使用的配置
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _selectedOneDragonFlowConfigName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 遮罩窗口配置
|
||||
/// </summary>
|
||||
@@ -134,11 +121,6 @@ public partial class AllConfig : ObservableObject
|
||||
/// 自动战斗配置
|
||||
/// </summary>
|
||||
public AutoFightConfig AutoFightConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动乐曲配置 - 千音雅集
|
||||
/// </summary>
|
||||
public AutoMusicGameConfig AutoMusicGameConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动秘境配置
|
||||
@@ -172,15 +154,6 @@ public partial class AllConfig : ObservableObject
|
||||
/// </summary>
|
||||
public NotificationConfig NotificationConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 原神按键绑定配置
|
||||
/// </summary>
|
||||
public KeyBindingsConfig KeyBindingsConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 传送相关配置
|
||||
/// </summary>
|
||||
public TpConfig TpConfig { get; set; } = new();
|
||||
[JsonIgnore]
|
||||
public Action? OnAnyChangedAction { get; set; }
|
||||
|
||||
@@ -192,7 +165,7 @@ public partial class AllConfig : ObservableObject
|
||||
GenshinStartConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
NotificationConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
NotificationConfig.PropertyChanged += OnNotificationPropertyChanged;
|
||||
KeyBindingsConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
|
||||
AutoPickConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoSkipConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoFishingConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
@@ -203,8 +176,7 @@ public partial class AllConfig : ObservableObject
|
||||
AutoWoodConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoFightConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoDomainConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoMusicGameConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
TpConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
|
||||
ScriptConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
}
|
||||
@@ -219,4 +191,4 @@ public partial class AllConfig : ObservableObject
|
||||
{
|
||||
NotificationService.Instance().RefreshNotifiers();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
@@ -27,22 +26,4 @@ public partial class CommonConfig : ObservableObject
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _exitToTray;
|
||||
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private WindowBackdropType _currentBackdropType = WindowBackdropType.Mica;
|
||||
|
||||
/// <summary>
|
||||
/// 是否是第一次运行
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _isFirstRun = true;
|
||||
|
||||
/// <summary>
|
||||
/// 这个版本是否运行过
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _runForVersion = string.Empty;
|
||||
}
|
||||
@@ -9,11 +9,11 @@ namespace BetterGenshinImpact.Core.Config;
|
||||
[Serializable]
|
||||
public partial class GenshinStartConfig : ObservableObject
|
||||
{
|
||||
// /// <summary>
|
||||
// /// 自动点击月卡
|
||||
// /// </summary>
|
||||
// [ObservableProperty]
|
||||
// private bool _autoClickBlessingOfTheWelkinMoonEnabled;
|
||||
/// <summary>
|
||||
/// 自动点击月卡
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoClickBlessingOfTheWelkinMoonEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// 自动进入游戏(开门)
|
||||
|
||||
@@ -211,12 +211,7 @@ public partial class HotKeyConfig : ObservableObject
|
||||
|
||||
[ObservableProperty]
|
||||
private string _keyMouseMacroRecordHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
// 暂停
|
||||
[ObservableProperty]
|
||||
private string _suspendHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _suspendHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
// 停止任意独立任务
|
||||
[ObservableProperty]
|
||||
private string _cancelTaskHotkey = "";
|
||||
|
||||
@@ -1,964 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using Windows.Networking.PushNotifications;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
/// <summary>
|
||||
/// 原神按键绑定配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class KeyBindingsConfig:ObservableObject
|
||||
{
|
||||
|
||||
#region Actions(操作)
|
||||
|
||||
/// <summary>
|
||||
/// 向前移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _moveForward = KeyId.W;
|
||||
|
||||
/// <summary>
|
||||
/// 向后移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _moveBackward = KeyId.S;
|
||||
|
||||
/// <summary>
|
||||
/// 向左移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _moveLeft = KeyId.A;
|
||||
|
||||
/// <summary>
|
||||
/// 向右移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _moveRight = KeyId.D;
|
||||
|
||||
/// <summary>
|
||||
/// 切换走/跑;特定操作模式下向下移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchToWalkOrRun = KeyId.LeftCtrl;
|
||||
|
||||
/// <summary>
|
||||
/// 普通攻击
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _normalAttack = KeyId.MouseLeftButton;
|
||||
|
||||
/// <summary>
|
||||
/// 元素战技
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _elementalSkill = KeyId.E;
|
||||
|
||||
/// <summary>
|
||||
/// 元素爆发
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _elementalBurst = KeyId.Q;
|
||||
|
||||
/// <summary>
|
||||
/// 冲刺(键盘)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _sprintKeyboard = KeyId.LeftShift;
|
||||
|
||||
/// <summary>
|
||||
/// 冲刺(鼠标)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _sprintMouse = KeyId.MouseRightButton;
|
||||
|
||||
/// <summary>
|
||||
/// 切换瞄准模式
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchAimingMode = KeyId.R;
|
||||
|
||||
/// <summary>
|
||||
/// 跳跃;特定操作模式下向上移动
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _jump = KeyId.Space;
|
||||
|
||||
/// <summary>
|
||||
/// 落下
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _drop = KeyId.X;
|
||||
|
||||
/// <summary>
|
||||
/// 拾取/交互(自动拾取由AutoPick模块管理)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _pickUpOrInteract = KeyId.F;
|
||||
|
||||
/// <summary>
|
||||
/// 快捷使用小道具
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _quickUseGadget = KeyId.Z;
|
||||
|
||||
/// <summary>
|
||||
/// 特定玩法内交互操作
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _interactionInSomeMode = KeyId.T;
|
||||
|
||||
/// <summary>
|
||||
/// 开启任务追踪
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _questNavigation = KeyId.V;
|
||||
|
||||
/// <summary>
|
||||
/// 中断挑战
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _abandonChallenge = KeyId.P;
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色1
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchMember1 = KeyId.D1;
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色2
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchMember2 = KeyId.D2;
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色3
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchMember3 = KeyId.D3;
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色4
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchMember4 = KeyId.D4;
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色5
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _switchMember5 = KeyId.D5;
|
||||
|
||||
/// <summary>
|
||||
/// 呼出快捷轮盘
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _shortcutWheel = KeyId.Tab;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menus(菜单)
|
||||
|
||||
/// <summary>
|
||||
/// 打开背包
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openInventory = KeyId.B;
|
||||
|
||||
/// <summary>
|
||||
/// 打开角色界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openCharacterScreen = KeyId.C;
|
||||
|
||||
/// <summary>
|
||||
/// 打开地图
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openMap = KeyId.M;
|
||||
|
||||
/// <summary>
|
||||
/// 打开派蒙界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openPaimonMenu = KeyId.Escape;
|
||||
|
||||
/// <summary>
|
||||
/// 打开冒险之证界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openAdventurerHandbook = KeyId.F1;
|
||||
|
||||
/// <summary>
|
||||
/// 打开多人游戏界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openCoOpScreen = KeyId.F2;
|
||||
|
||||
/// <summary>
|
||||
/// 打开祈愿界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openWishScreen = KeyId.F3;
|
||||
|
||||
/// <summary>
|
||||
/// 打开纪行界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openBattlePassScreen = KeyId.F4;
|
||||
|
||||
/// <summary>
|
||||
/// 打开活动面板
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openTheEventsMenu = KeyId.F5;
|
||||
|
||||
/// <summary>
|
||||
/// 打开玩法系统界面(尘歌壶内猫尾酒馆内)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openTheSettingsMenu = KeyId.F6;
|
||||
|
||||
/// <summary>
|
||||
/// 打开摆设界面(尘歌壶内)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openTheFurnishingScreen = KeyId.F7;
|
||||
|
||||
/// <summary>
|
||||
/// 打开星之归还(条件符合期间生效)
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openStellarReunion = KeyId.F8;
|
||||
|
||||
/// <summary>
|
||||
/// 开关任务菜单
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openQuestMenu = KeyId.J;
|
||||
|
||||
/// <summary>
|
||||
/// 打开通知详情
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openNotificationDetails = KeyId.Y;
|
||||
|
||||
/// <summary>
|
||||
/// 打开聊天界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openChatScreen = KeyId.Enter;
|
||||
|
||||
/// <summary>
|
||||
/// 打开特殊环境说明
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openSpecialEnvironmentInformation = KeyId.U;
|
||||
|
||||
/// <summary>
|
||||
/// 查看教程详情
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _checkTutorialDetails = KeyId.G;
|
||||
|
||||
/// <summary>
|
||||
/// 长按打开元素视野
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _elementalSight = KeyId.MouseMiddleButton;
|
||||
|
||||
/// <summary>
|
||||
/// 呼出鼠标
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _showCursor = KeyId.LeftAlt;
|
||||
|
||||
/// <summary>
|
||||
/// 打开队伍配置界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openPartySetupScreen = KeyId.L;
|
||||
|
||||
/// <summary>
|
||||
/// 打开好友界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _openFriendsScreen = KeyId.O;
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏主界面
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private KeyId _hideUI = KeyId.Slash;
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public static class KeyIdConverter
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 将KeyId转换为字符串(可在后续支持多语言),按键名称的显示尽量与原神UI一致
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToName(this KeyId value)
|
||||
{
|
||||
return ToChineseName(value);
|
||||
}
|
||||
|
||||
private static string ToChineseName(KeyId value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
// 需要单独翻译的按键
|
||||
KeyId.None => "<未指定>",
|
||||
KeyId.Unknown => "<未知>",
|
||||
KeyId.MouseLeftButton => "鼠标左键",
|
||||
KeyId.MouseRightButton => "鼠标右键",
|
||||
KeyId.MouseMiddleButton => "鼠标中键",
|
||||
KeyId.MouseSideButton1 => "鼠标侧键1",
|
||||
KeyId.MouseSideButton2 => "鼠标侧键2",
|
||||
KeyId.Apps => "菜单键",
|
||||
// 无需单独翻译的部分
|
||||
_ => EnglishKeyNameToChinese(value),
|
||||
};
|
||||
}
|
||||
|
||||
private static string EnglishKeyNameToChinese(KeyId value)
|
||||
{
|
||||
var engName = ToEnglishName(value);
|
||||
if (engName.StartsWith("Left ") || engName.StartsWith("Right "))
|
||||
{
|
||||
return engName.Replace("Left ", "左").Replace("Right ", "右");
|
||||
}
|
||||
return engName;
|
||||
}
|
||||
|
||||
private static string ToEnglishName(KeyId value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
// 需要转换的部分
|
||||
KeyId.None => "<None>",
|
||||
KeyId.Unknown => "<Unknown>",
|
||||
KeyId.MouseLeftButton => "Mouse LButton",
|
||||
KeyId.MouseRightButton => "Mouse RButton",
|
||||
KeyId.MouseMiddleButton => "Mouse MButton",
|
||||
KeyId.MouseSideButton1 => "Mouse XButton1",
|
||||
KeyId.MouseSideButton2 => "Mouse XButton2",
|
||||
KeyId.Escape => "Esc",
|
||||
KeyId.PageUp => "Page Up",
|
||||
KeyId.PageDown => "Page Down",
|
||||
KeyId.CapsLock => "Caps Lock",
|
||||
KeyId.ScrollLock => "Scroll Lock",
|
||||
KeyId.LeftShift => "Left Shift",
|
||||
KeyId.RightShift => "Right Shift",
|
||||
KeyId.LeftCtrl => "Left Crtl",
|
||||
KeyId.RightCtrl => "Right Ctrl",
|
||||
KeyId.LeftAlt => "Left Alt",
|
||||
KeyId.RightAlt => "Right Alt",
|
||||
KeyId.LeftWin => "Left Win",
|
||||
KeyId.RightWin => "Right Win",
|
||||
KeyId.Apps => "Menu",
|
||||
KeyId.Left => "←",
|
||||
KeyId.Up => "↑",
|
||||
KeyId.Right => "→",
|
||||
KeyId.Down => "↓",
|
||||
KeyId.D0 => "0",
|
||||
KeyId.D1 => "1",
|
||||
KeyId.D2 => "2",
|
||||
KeyId.D3 => "3",
|
||||
KeyId.D4 => "4",
|
||||
KeyId.D5 => "5",
|
||||
KeyId.D6 => "6",
|
||||
KeyId.D7 => "7",
|
||||
KeyId.D8 => "8",
|
||||
KeyId.D9 => "9",
|
||||
KeyId.Apostrophe => "'",
|
||||
KeyId.Comma => ",",
|
||||
KeyId.Minus => "-",
|
||||
KeyId.Equal => "=",
|
||||
KeyId.Period => ".",
|
||||
KeyId.Slash => "/",
|
||||
KeyId.Backslash => @"\",
|
||||
KeyId.Semicolon => ";",
|
||||
KeyId.LeftSquareBracket => "[",
|
||||
KeyId.RightSquareBracket => "]",
|
||||
KeyId.Tilde => "`",
|
||||
KeyId.NumLock => "Num Lock",
|
||||
KeyId.NumPad0 => "Num 0",
|
||||
KeyId.NumPad1 => "Num 1",
|
||||
KeyId.NumPad2 => "Num 2",
|
||||
KeyId.NumPad3 => "Num 3",
|
||||
KeyId.NumPad4 => "Num 4",
|
||||
KeyId.NumPad5 => "Num 5",
|
||||
KeyId.NumPad6 => "Num 6",
|
||||
KeyId.NumPad7 => "Num 7",
|
||||
KeyId.NumPad8 => "Num 8",
|
||||
KeyId.NumPad9 => "Num 9",
|
||||
KeyId.Decimal => "Num .",
|
||||
KeyId.Divide => "Num /",
|
||||
KeyId.Multiply => "Num *",
|
||||
KeyId.Subtract => "Num -",
|
||||
KeyId.Add => "Num +",
|
||||
KeyId.NumEnter => "Num Enter",
|
||||
// 默认使用枚举名
|
||||
_ => value.ToString(),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将KeyId转换为VK
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static VK ToVK(this KeyId value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
// 这两个值在VK中没有,抛异常
|
||||
KeyId.None => throw new ArgumentOutOfRangeException(nameof(value), "未指定按键,无法转换为VK。"),
|
||||
KeyId.Unknown => throw new ArgumentOutOfRangeException(nameof(value), "未知按键,无法转换为VK。"),
|
||||
// 剩下的值相同,直接转
|
||||
_ => (VK)value,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将KeyId转换为System.Windows.Input.Key
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static Key ToInputKey(this KeyId value)
|
||||
{
|
||||
// 部分按键名称相同,使用名称转换
|
||||
try
|
||||
{
|
||||
return Enum.Parse<Key>(value.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 其他键使用查表法转换
|
||||
return value switch
|
||||
{
|
||||
KeyId.LeftWin => Key.LWin,
|
||||
KeyId.RightWin => Key.RWin,
|
||||
KeyId.Apostrophe => Key.Oem7,
|
||||
KeyId.Comma => Key.OemComma,
|
||||
KeyId.Minus => Key.OemMinus,
|
||||
KeyId.Equal => Key.OemPlus,
|
||||
KeyId.Period => Key.OemPeriod,
|
||||
KeyId.Slash => Key.Oem2,
|
||||
KeyId.Semicolon => Key.Oem1,
|
||||
KeyId.LeftSquareBracket => Key.Oem4,
|
||||
KeyId.Backslash => Key.Oem5,
|
||||
KeyId.RightSquareBracket => Key.Oem6,
|
||||
KeyId.Tilde => Key.Oem3,
|
||||
KeyId.Enter => Key.Enter,
|
||||
KeyId.ScrollLock => Key.Scroll,
|
||||
KeyId.PageUp => Key.Prior,
|
||||
KeyId.PageDown => Key.Next,
|
||||
KeyId.Backspace => Key.Back,
|
||||
KeyId.CapsLock => Key.Capital,
|
||||
// None、Unknown和鼠标按键抛异常
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value)),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将KeyId转换为MouseButton
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public static MouseButton ToMouseButton(this KeyId value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
KeyId.MouseLeftButton => MouseButton.Left,
|
||||
KeyId.MouseRightButton => MouseButton.Right,
|
||||
KeyId.MouseMiddleButton => MouseButton.Middle,
|
||||
KeyId.MouseSideButton1 => MouseButton.XButton1,
|
||||
KeyId.MouseSideButton2 => MouseButton.XButton2,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(value), "键盘按键请使用ToInputKey方法"),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// [实验] 将KeyId转换为WinForm中的Keys(用于兼容按键连发功能)
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static Keys ToWinFormKeys(this KeyId value)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Enum.Parse<Keys>(value.ToInputKey().ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将VK转换为KeyId
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyId FromVK(VK value)
|
||||
{
|
||||
// 尝试通过VK的值获取KeyId的枚举名。若成功,表示对应的VK在KeyId支持的范围内,直接转换;否则返回Unknown
|
||||
return string.IsNullOrEmpty(Enum.GetName(typeof(KeyId), value)) ? KeyId.Unknown : (KeyId)value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将System.Windows.Input.Key转换为KeyId
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyId FromInputKey(Key value)
|
||||
{
|
||||
// 部分按键名称相同,使用名称转换
|
||||
try
|
||||
{
|
||||
return Enum.Parse<KeyId>(value.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 其他键使用查表法转换
|
||||
return value switch
|
||||
{
|
||||
Key.LWin => KeyId.LeftWin,
|
||||
Key.RWin => KeyId.RightWin,
|
||||
Key.Oem7 => KeyId.Apostrophe,
|
||||
Key.OemComma => KeyId.Comma,
|
||||
Key.OemMinus => KeyId.Minus,
|
||||
Key.OemPlus => KeyId.Equal,
|
||||
Key.OemPeriod => KeyId.Period,
|
||||
Key.Oem2 => KeyId.Slash,
|
||||
Key.Oem1 => KeyId.Semicolon,
|
||||
Key.Oem4 => KeyId.LeftSquareBracket,
|
||||
Key.Oem5 => KeyId.Backslash,
|
||||
Key.Oem6 => KeyId.RightSquareBracket,
|
||||
Key.Oem3 => KeyId.Tilde,
|
||||
Key.Enter => KeyId.Enter,
|
||||
Key.Scroll => KeyId.ScrollLock,
|
||||
Key.Prior => KeyId.PageUp,
|
||||
Key.Next => KeyId.PageDown,
|
||||
Key.Back => KeyId.Backspace,
|
||||
Key.Capital => KeyId.CapsLock,
|
||||
// 支持列表外的值返回Unknown
|
||||
_ => KeyId.Unknown,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将MouseButton转换为KeyId
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyId FromMouseButton(MouseButton value)
|
||||
{
|
||||
return value switch
|
||||
{
|
||||
MouseButton.Left => KeyId.MouseLeftButton,
|
||||
MouseButton.Right => KeyId.MouseRightButton,
|
||||
MouseButton.Middle => KeyId.MouseMiddleButton,
|
||||
MouseButton.XButton1 => KeyId.MouseSideButton1,
|
||||
MouseButton.XButton2 => KeyId.MouseSideButton2,
|
||||
_ => KeyId.Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于与VK/Windows.Input.Key解耦,值与VK对应,但是仅包含美式键盘(104键,不包括媒体控制等)和鼠标中的按键
|
||||
/// </summary>
|
||||
public enum KeyId
|
||||
{
|
||||
/// <summary>无</summary>
|
||||
None = 0x00,
|
||||
|
||||
/// <summary>未知按键</summary>
|
||||
Unknown = 0xFF,
|
||||
|
||||
#region 鼠标按键
|
||||
|
||||
/// <summary>鼠标左键</summary>
|
||||
MouseLeftButton = 0x01,
|
||||
|
||||
/// <summary>鼠标右键</summary>
|
||||
MouseRightButton = 0x02,
|
||||
|
||||
/// <summary>鼠标中键(滚轮)</summary>
|
||||
MouseMiddleButton = 0x04,
|
||||
|
||||
/// <summary>鼠标侧键1(后退)</summary>
|
||||
MouseSideButton1 = 0x05,
|
||||
|
||||
/// <summary>鼠标侧键2(前进)</summary>
|
||||
MouseSideButton2 = 0x06,
|
||||
|
||||
#endregion
|
||||
|
||||
#region F键区
|
||||
|
||||
/// <summary>F1</summary>
|
||||
F1 = 0x70,
|
||||
|
||||
/// <summary>F2</summary>
|
||||
F2 = 0x71,
|
||||
|
||||
/// <summary>F3</summary>
|
||||
F3 = 0x72,
|
||||
|
||||
/// <summary>F4</summary>
|
||||
F4 = 0x73,
|
||||
|
||||
/// <summary>F5</summary>
|
||||
F5 = 0x74,
|
||||
|
||||
/// <summary>F6</summary>
|
||||
F6 = 0x75,
|
||||
|
||||
/// <summary>F7</summary>
|
||||
F7 = 0x76,
|
||||
|
||||
/// <summary>F8</summary>
|
||||
F8 = 0x77,
|
||||
|
||||
/// <summary>F9</summary>
|
||||
F9 = 0x78,
|
||||
|
||||
/// <summary>F10</summary>
|
||||
F10 = 0x79,
|
||||
|
||||
/// <summary>F11</summary>
|
||||
F11 = 0x7A,
|
||||
|
||||
/// <summary>F12</summary>
|
||||
F12 = 0x7B,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 控制&功能键
|
||||
|
||||
/// <summary>Esc</summary>
|
||||
Escape = 0x1B,
|
||||
|
||||
/// <summary>PrintScreen</summary>
|
||||
PrintScreen = 0x2C,
|
||||
|
||||
/// <summary>ScrollLock</summary>
|
||||
ScrollLock = 0x91,
|
||||
|
||||
/// <summary>Pause</summary>
|
||||
Pause = 0x13,
|
||||
|
||||
/// <summary>Insert</summary>
|
||||
Insert = 0x2D,
|
||||
|
||||
/// <summary>Delete</summary>
|
||||
Delete = 0x2E,
|
||||
|
||||
/// <summary>Home</summary>
|
||||
Home = 0x24,
|
||||
|
||||
/// <summary>End</summary>
|
||||
End = 0x23,
|
||||
|
||||
/// <summary>Page Up</summary>
|
||||
PageUp = 0x21,
|
||||
|
||||
/// <summary>Page Down</summary>
|
||||
PageDown = 0x22,
|
||||
|
||||
/// <summary>Backspace退格</summary>
|
||||
Backspace = 0x08,
|
||||
|
||||
/// <summary>Tab</summary>
|
||||
Tab = 0x09,
|
||||
|
||||
/// <summary>Caps Lock大写锁定</summary>
|
||||
CapsLock = 0x14,
|
||||
|
||||
/// <summary>Enter回车</summary>
|
||||
Enter = 0x0D,
|
||||
|
||||
///// <summary>Shift</summary>
|
||||
//Shift = 0x10,
|
||||
|
||||
/// <summary>左Shift</summary>
|
||||
LeftShift = 0xA0,
|
||||
|
||||
/// <summary>右Shift</summary>
|
||||
RightShift = 0xA1,
|
||||
|
||||
///// <summary>Ctrl</summary>
|
||||
//Ctrl = 0x11,
|
||||
|
||||
/// <summary>左Ctrl</summary>
|
||||
LeftCtrl = 0xA2,
|
||||
|
||||
/// <summary>右Ctrl</summary>
|
||||
RightCtrl = 0xA3,
|
||||
|
||||
///// <summary>Alt</summary>
|
||||
//Alt = 0x12,
|
||||
|
||||
/// <summary>左Alt</summary>
|
||||
LeftAlt = 0xA4,
|
||||
|
||||
/// <summary>右Alt</summary>
|
||||
RightAlt = 0xA5,
|
||||
|
||||
/// <summary>左Win键 (Microsoft Natural Keyboard)</summary>
|
||||
LeftWin = 0x5B,
|
||||
|
||||
/// <summary>右Win键 (Microsoft Natural Keyboard)</summary>
|
||||
RightWin = 0x5C,
|
||||
|
||||
/// <summary>菜单键 (Microsoft Natural Keyboard)</summary>
|
||||
Apps = 0x5D,
|
||||
|
||||
/// <summary>Space空格键</summary>
|
||||
Space = 0x20,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 方向键
|
||||
|
||||
/// <summary>方向键 ←</summary>
|
||||
Left = 0x25,
|
||||
|
||||
/// <summary>方向键 ↑</summary>
|
||||
Up = 0x26,
|
||||
|
||||
/// <summary>方向键 →</summary>
|
||||
Right = 0x27,
|
||||
|
||||
/// <summary>方向键 ↓</summary>
|
||||
Down = 0x28,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 字母区 - 字母
|
||||
|
||||
/// <summary>A</summary>
|
||||
A = 0x41,
|
||||
|
||||
/// <summary>B</summary>
|
||||
B = 0x42,
|
||||
|
||||
/// <summary>C</summary>
|
||||
C = 0x43,
|
||||
|
||||
/// <summary>D</summary>
|
||||
D = 0x44,
|
||||
|
||||
/// <summary>E</summary>
|
||||
E = 0x45,
|
||||
|
||||
/// <summary>F</summary>
|
||||
F = 0x46,
|
||||
|
||||
/// <summary>G</summary>
|
||||
G = 0x47,
|
||||
|
||||
/// <summary>H</summary>
|
||||
H = 0x48,
|
||||
|
||||
/// <summary>I</summary>
|
||||
I = 0x49,
|
||||
|
||||
/// <summary>J</summary>
|
||||
J = 0x4A,
|
||||
|
||||
/// <summary>K</summary>
|
||||
K = 0x4B,
|
||||
|
||||
/// <summary>L</summary>
|
||||
L = 0x4C,
|
||||
|
||||
/// <summary>M</summary>
|
||||
M = 0x4D,
|
||||
|
||||
/// <summary>N</summary>
|
||||
N = 0x4E,
|
||||
|
||||
/// <summary>O</summary>
|
||||
O = 0x4F,
|
||||
|
||||
/// <summary>P</summary>
|
||||
P = 0x50,
|
||||
|
||||
/// <summary>Q</summary>
|
||||
Q = 0x51,
|
||||
|
||||
/// <summary>R</summary>
|
||||
R = 0x52,
|
||||
|
||||
/// <summary>S</summary>
|
||||
S = 0x53,
|
||||
|
||||
/// <summary>T</summary>
|
||||
T = 0x54,
|
||||
|
||||
/// <summary>U</summary>
|
||||
U = 0x55,
|
||||
|
||||
/// <summary>V</summary>
|
||||
V = 0x56,
|
||||
|
||||
/// <summary>W</summary>
|
||||
W = 0x57,
|
||||
|
||||
/// <summary>X</summary>
|
||||
X = 0x58,
|
||||
|
||||
/// <summary>Y</summary>
|
||||
Y = 0x59,
|
||||
|
||||
/// <summary>Z</summary>
|
||||
Z = 0x5A,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 字母区 - 数字
|
||||
|
||||
/// <summary>0</summary>
|
||||
D0 = 0x30,
|
||||
|
||||
/// <summary>1</summary>
|
||||
D1 = 0x31,
|
||||
|
||||
/// <summary>2</summary>
|
||||
D2 = 0x32,
|
||||
|
||||
/// <summary>3</summary>
|
||||
D3 = 0x33,
|
||||
|
||||
/// <summary>4</summary>
|
||||
D4 = 0x34,
|
||||
|
||||
/// <summary>5</summary>
|
||||
D5 = 0x35,
|
||||
|
||||
/// <summary>6</summary>
|
||||
D6 = 0x36,
|
||||
|
||||
/// <summary>7</summary>
|
||||
D7 = 0x37,
|
||||
|
||||
/// <summary>8</summary>
|
||||
D8 = 0x38,
|
||||
|
||||
/// <summary>9</summary>
|
||||
D9 = 0x39,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 字母区 - 符号
|
||||
|
||||
/// <summary>引号 '</summary>
|
||||
Apostrophe = 0xDE,
|
||||
|
||||
/// <summary>逗号 ,</summary>
|
||||
Comma = 0xBC,
|
||||
|
||||
/// <summary>连接符 -</summary>
|
||||
Minus = 0xBD,
|
||||
|
||||
/// <summary>等于号 =</summary>
|
||||
Equal = 0xBB,
|
||||
|
||||
/// <summary>句号 .</summary>
|
||||
Period = 0xBE,
|
||||
|
||||
/// <summary>斜杠 /</summary>
|
||||
Slash = 0xBF,
|
||||
|
||||
/// <summary>反斜杠 \</summary>
|
||||
Backslash = 0xE2,
|
||||
|
||||
/// <summary>分号 ;</summary>
|
||||
Semicolon = 0xBA,
|
||||
|
||||
/// <summary>左方括号 [</summary>
|
||||
LeftSquareBracket = 0xDB,
|
||||
|
||||
/// <summary>右方括号 ]</summary>
|
||||
RightSquareBracket = 0xDD,
|
||||
|
||||
/// <summary>波浪号 `</summary>
|
||||
Tilde = 0xC0,
|
||||
|
||||
#endregion
|
||||
|
||||
#region 小键盘区
|
||||
|
||||
/// <summary>Num Lock</summary>
|
||||
NumLock = 0x90,
|
||||
|
||||
/// <summary>Num 0</summary>
|
||||
NumPad0 = 0x60,
|
||||
|
||||
/// <summary>Num 1</summary>
|
||||
NumPad1 = 0x61,
|
||||
|
||||
/// <summary>Num 2</summary>
|
||||
NumPad2 = 0x62,
|
||||
|
||||
/// <summary>Num 3</summary>
|
||||
NumPad3 = 0x63,
|
||||
|
||||
/// <summary>Num 4</summary>
|
||||
NumPad4 = 0x64,
|
||||
|
||||
/// <summary>Num 5</summary>
|
||||
NumPad5 = 0x65,
|
||||
|
||||
/// <summary>Num 6</summary>
|
||||
NumPad6 = 0x66,
|
||||
|
||||
/// <summary>Num 7</summary>
|
||||
NumPad7 = 0x67,
|
||||
|
||||
/// <summary>Num 8</summary>
|
||||
NumPad8 = 0x68,
|
||||
|
||||
/// <summary>Num 9</summary>
|
||||
NumPad9 = 0x69,
|
||||
|
||||
/// <summary>Num .</summary>
|
||||
Decimal = 0x6E,
|
||||
|
||||
/// <summary>Num /</summary>
|
||||
Divide = 0x6F,
|
||||
|
||||
/// <summary>Num *</summary>
|
||||
Multiply = 0x6A,
|
||||
|
||||
/// <summary>Num -</summary>
|
||||
Subtract = 0x6D,
|
||||
|
||||
/// <summary>Num +</summary>
|
||||
Add = 0x6B,
|
||||
|
||||
/// <summary>Num Enter</summary>
|
||||
NumEnter = 0x0E,
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
[Serializable]
|
||||
public partial class OneDragonFlowConfig : ObservableObject
|
||||
{
|
||||
// 配置名
|
||||
[ObservableProperty]
|
||||
private string _name = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 所有任务的开关状态
|
||||
/// </summary>
|
||||
public Dictionary<string, bool> TaskEnabledList { get; set; } = new();
|
||||
|
||||
// 合成树脂的国家
|
||||
[ObservableProperty]
|
||||
private string _craftingBenchCountry = "枫丹";
|
||||
|
||||
// 冒险者协会的国家
|
||||
[ObservableProperty]
|
||||
private string _adventurersGuildCountry = "枫丹";
|
||||
|
||||
// 自动战斗配置的队伍名称
|
||||
[ObservableProperty]
|
||||
private string _partyName = string.Empty;
|
||||
|
||||
// 自动战斗配置的策略名称
|
||||
[ObservableProperty]
|
||||
private string _domainName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _weeklyDomainEnabled = false;
|
||||
|
||||
// 领取每日奖励的好感队伍名称
|
||||
[ObservableProperty]
|
||||
private string _dailyRewardPartyName = string.Empty;
|
||||
|
||||
|
||||
#region 每周秘境配置
|
||||
|
||||
[ObservableProperty]
|
||||
private string _mondayThursdayPartyName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _mondayThursdayDomainName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _tuesdayFridayPartyName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _tuesdayFridayDomainName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _wednesdaySaturdayPartyName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _wednesdaySaturdayDomainName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _sundayPartyName = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _sundayDomainName = string.Empty;
|
||||
|
||||
// 通过当天是哪一天来返回配置
|
||||
public (string partyName, string domainName) GetDomainConfig()
|
||||
{
|
||||
if (WeeklyDomainEnabled)
|
||||
{
|
||||
var dayOfWeek = DateTime.Now.DayOfWeek;
|
||||
return dayOfWeek switch
|
||||
{
|
||||
DayOfWeek.Monday => (MondayThursdayPartyName, MondayThursdayDomainName),
|
||||
DayOfWeek.Tuesday => (TuesdayFridayPartyName, TuesdayFridayDomainName),
|
||||
DayOfWeek.Wednesday => (WednesdaySaturdayPartyName, WednesdaySaturdayDomainName),
|
||||
DayOfWeek.Thursday => (MondayThursdayPartyName, MondayThursdayDomainName),
|
||||
DayOfWeek.Friday => (TuesdayFridayPartyName, TuesdayFridayDomainName),
|
||||
DayOfWeek.Saturday => (WednesdaySaturdayPartyName, WednesdaySaturdayDomainName),
|
||||
DayOfWeek.Sunday => (SundayPartyName, SundayDomainName),
|
||||
_ => (PartyName, DomainName)
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PartyName, DomainName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
new Condition
|
||||
{
|
||||
Subject = "队伍中角色",
|
||||
Object = ["绮良良", "莱依拉", "茜特菈莉", "芭芭拉", "七七"],
|
||||
Object = ["绮良良", "莱依拉", "芭芭拉", "七七"],
|
||||
Result = "循环短E"
|
||||
},
|
||||
|
||||
@@ -43,13 +43,6 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
Subject = "队伍中角色",
|
||||
Object = ["钟离"],
|
||||
Result = "循环长E"
|
||||
},
|
||||
|
||||
new Condition
|
||||
{
|
||||
Subject = "队伍中角色",
|
||||
Object = ["迪希雅"],
|
||||
Result = "作为主要行走角色"
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -113,7 +106,7 @@ public partial class PathingConditionConfig : ObservableObject
|
||||
/// <returns></returns>
|
||||
public PathingPartyConfig BuildPartyConfigByCondition(CombatScenes combatScenes)
|
||||
{
|
||||
PathingPartyConfig partyConfig = PathingPartyConfig.BuildDefault();
|
||||
PathingPartyConfig partyConfig = new();
|
||||
// 使用最优先匹配上的条件
|
||||
foreach (var avatarCondition in AvatarConditions)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
@@ -61,18 +60,6 @@ public partial class PathingPartyConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _onlyInTeleportRecover = false;
|
||||
|
||||
//允许在jsScript脚本中使用此路径追踪配置
|
||||
[ObservableProperty]
|
||||
private bool _jsScriptUseEnabled = false;
|
||||
|
||||
//允许在此调度器中(一般在JS脚本中)调用自动战斗任务时,采用此追踪配置里的战斗策略
|
||||
[ObservableProperty]
|
||||
private bool _soloTaskUseFightEnabled = false;
|
||||
|
||||
//不在某时执行
|
||||
[ObservableProperty]
|
||||
private string _skipDuring = "";
|
||||
|
||||
// 使用小道具的间隔时间
|
||||
[ObservableProperty]
|
||||
private int _useGadgetIntervalMs = 0;
|
||||
@@ -81,17 +68,6 @@ public partial class PathingPartyConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _autoSkipEnabled = true;
|
||||
|
||||
// 自动冲刺启用
|
||||
[ObservableProperty]
|
||||
private bool _autoRunEnabled = true;
|
||||
|
||||
//启用自动战斗配置
|
||||
[ObservableProperty]
|
||||
private bool _autoFightEnabled = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private AutoFightConfig _autoFightConfig = new();
|
||||
|
||||
public static PathingPartyConfig BuildDefault()
|
||||
{
|
||||
// 即便是不启用的情况下也设置默认值,减少后续使用的判断
|
||||
|
||||
@@ -3,7 +3,6 @@ using SharpDX.DirectInput;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Monitor;
|
||||
|
||||
@@ -12,8 +11,6 @@ public class DirectInputMonitor : IDisposable
|
||||
private bool _isRunning = true;
|
||||
|
||||
private readonly Mouse _mouse;
|
||||
|
||||
public static int Interval = 5;
|
||||
|
||||
public DirectInputMonitor()
|
||||
{
|
||||
@@ -37,8 +34,8 @@ public class DirectInputMonitor : IDisposable
|
||||
_mouse.Acquire();
|
||||
MouseState state = _mouse.GetCurrentState();
|
||||
// Debug.WriteLine($"{state.X} {state.Y} {state.Buttons[0]} {state.Buttons[1]}");
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookMouseMoveBy(state, Kernel32.GetTickCount());
|
||||
Thread.Sleep(Interval); // 10ms, equivalent to CLOCKS_PER_SEC/100
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookMouseMoveBy(state);
|
||||
Thread.Sleep(5); // 10ms, equivalent to CLOCKS_PER_SEC/100
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recorder;
|
||||
using BetterGenshinImpact.Core.Recorder;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.Model;
|
||||
@@ -19,10 +18,6 @@ public class MouseKeyMonitor
|
||||
/// </summary>
|
||||
private readonly Timer _fTimer = new();
|
||||
|
||||
private Keys _pickUpKey = Keys.F;
|
||||
|
||||
private User32.VK _pickUpKeyCode = User32.VK.VK_F;
|
||||
|
||||
//private readonly Random _random = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -30,10 +25,6 @@ public class MouseKeyMonitor
|
||||
/// </summary>
|
||||
private readonly Timer _spaceTimer = new();
|
||||
|
||||
private Keys _releaseControlKey = Keys.Space;
|
||||
|
||||
private User32.VK _releaseControlKeyCode = User32.VK.VK_SPACE;
|
||||
|
||||
private DateTime _firstFKeyDownTime = DateTime.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
@@ -55,33 +46,27 @@ public class MouseKeyMonitor
|
||||
_globalHook.MouseDownExt += GlobalHookMouseDownExt;
|
||||
_globalHook.MouseUpExt += GlobalHookMouseUpExt;
|
||||
_globalHook.MouseMoveExt += GlobalHookMouseMoveExt;
|
||||
_globalHook.MouseWheelExt += GlobalHookMouseWheelExt;
|
||||
//_globalHook.KeyPress += GlobalHookKeyPress;
|
||||
|
||||
_pickUpKey = TaskContext.Instance().Config.KeyBindingsConfig.PickUpOrInteract.ToWinFormKeys();
|
||||
_pickUpKeyCode = TaskContext.Instance().Config.KeyBindingsConfig.PickUpOrInteract.ToVK();
|
||||
_releaseControlKey = TaskContext.Instance().Config.KeyBindingsConfig.Jump.ToWinFormKeys();
|
||||
_releaseControlKeyCode = TaskContext.Instance().Config.KeyBindingsConfig.Jump.ToVK();
|
||||
|
||||
_firstSpaceKeyDownTime = DateTime.MaxValue;
|
||||
var si = TaskContext.Instance().Config.MacroConfig.SpaceFireInterval;
|
||||
_spaceTimer.Interval = si;
|
||||
_spaceTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(_releaseControlKeyCode); };
|
||||
_spaceTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(User32.VK.VK_SPACE); };
|
||||
|
||||
var fi = TaskContext.Instance().Config.MacroConfig.FFireInterval;
|
||||
_fTimer.Interval = fi;
|
||||
_fTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(_pickUpKeyCode); };
|
||||
_fTimer.Elapsed += (sender, args) => { Simulation.PostMessage(_hWnd).KeyPress(User32.VK.VK_F); };
|
||||
}
|
||||
|
||||
private void GlobalHookKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
// Debug.WriteLine("KeyDown: \t{0}", e.KeyCode);
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookKeyDown(e, Kernel32.GetTickCount());
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookKeyDown(e);
|
||||
|
||||
// 热键按下事件
|
||||
HotKeyDown(sender, e);
|
||||
|
||||
if (e.KeyCode == _releaseControlKey)
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
if (_firstSpaceKeyDownTime == DateTime.MaxValue)
|
||||
{
|
||||
@@ -95,7 +80,7 @@ public class MouseKeyMonitor
|
||||
_spaceTimer.Start();
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == _pickUpKey)
|
||||
else if (e.KeyCode == Keys.F)
|
||||
{
|
||||
if (_firstFKeyDownTime == DateTime.MaxValue)
|
||||
{
|
||||
@@ -114,12 +99,12 @@ public class MouseKeyMonitor
|
||||
private void GlobalHookKeyUp(object? sender, KeyEventArgs e)
|
||||
{
|
||||
// Debug.WriteLine("KeyUp: \t{0}", e.KeyCode);
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookKeyUp(e, Kernel32.GetTickCount());
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookKeyUp(e);
|
||||
|
||||
// 热键松开事件
|
||||
HotKeyUp(sender, e);
|
||||
|
||||
if (e.KeyCode == _releaseControlKey)
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
if (_firstSpaceKeyDownTime != DateTime.MaxValue)
|
||||
{
|
||||
@@ -129,7 +114,7 @@ public class MouseKeyMonitor
|
||||
_spaceTimer.Stop();
|
||||
}
|
||||
}
|
||||
else if (e.KeyCode == _pickUpKey)
|
||||
else if (e.KeyCode == Keys.F)
|
||||
{
|
||||
if (_firstFKeyDownTime != DateTime.MaxValue)
|
||||
{
|
||||
@@ -181,12 +166,6 @@ public class MouseKeyMonitor
|
||||
// Debug.WriteLine("MouseMove: {0}; \t Location: {1};\t System Timestamp: {2}", e.Button, e.Location, e.Timestamp);
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookMouseMoveTo(e);
|
||||
}
|
||||
|
||||
private void GlobalHookMouseWheelExt(object? sender, MouseEventExtArgs e)
|
||||
{
|
||||
// Debug.WriteLine("MouseMove: {0}; \t Location: {1};\t Delta: {2};\t System Timestamp: {3}", e.Button, e.Location, e.Delta, e.Timestamp);
|
||||
GlobalKeyMouseRecord.Instance.GlobalHookMouseWheel(e);
|
||||
}
|
||||
|
||||
public void Unsubscribe()
|
||||
{
|
||||
@@ -197,7 +176,6 @@ public class MouseKeyMonitor
|
||||
_globalHook.MouseDownExt -= GlobalHookMouseDownExt;
|
||||
_globalHook.MouseUpExt -= GlobalHookMouseUpExt;
|
||||
_globalHook.MouseMoveExt -= GlobalHookMouseMoveExt;
|
||||
_globalHook.MouseWheelExt -= GlobalHookMouseWheelExt;
|
||||
//_globalHook.KeyPress -= GlobalHookKeyPress;
|
||||
_globalHook.Dispose();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
|
||||
@@ -46,16 +45,6 @@ public class BgiYoloV8Predictor(string modelRelativePath) : IDisposable
|
||||
}
|
||||
}
|
||||
Debug.WriteLine("YOLOv8识别结果:" + JsonSerializer.Serialize(dict));
|
||||
|
||||
var list = new List<RectDrawable>();
|
||||
foreach (var box in result.Boxes)
|
||||
{
|
||||
var rect = new Rect(box.Bounds.X, box.Bounds.Y, box.Bounds.Width, box.Bounds.Height);
|
||||
list.Add(region.ToRectDrawable(rect, modelRelativePath));
|
||||
}
|
||||
|
||||
VisionContext.Instance().DrawContent.PutOrRemoveRectList(modelRelativePath, list);
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
|
||||
public class BgiYoloV8PredictorFactory
|
||||
{
|
||||
static Dictionary<string, BgiYoloV8Predictor> _predictors = new();
|
||||
|
||||
public static BgiYoloV8Predictor GetPredictor(string modelRelativePath)
|
||||
{
|
||||
if (!_predictors.ContainsKey(modelRelativePath))
|
||||
{
|
||||
_predictors[modelRelativePath] = new BgiYoloV8Predictor(modelRelativePath);
|
||||
}
|
||||
|
||||
return _predictors[modelRelativePath];
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using OpenCvSharp.XFeatures2D;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
@@ -136,10 +137,10 @@ public class FeatureMatcher
|
||||
/// <summary>
|
||||
/// 合并邻近的特征点后匹配(临近特征)
|
||||
/// </summary>
|
||||
/// <param name="queryMat">查询图像的 Mat 对象。</param>
|
||||
/// <param name="queryMat">查询的图</param>
|
||||
/// <param name="prevX">上次匹配到的坐标x</param>
|
||||
/// <param name="prevY">上次匹配到的坐标y</param>
|
||||
/// <param name="queryMatMask">查询图像的 Mask,用于限定检测特征的区域。</param>
|
||||
/// <param name="queryMatMask">查询Mask</param>
|
||||
/// <returns></returns>
|
||||
public Point2f Match(Mat queryMat, float prevX, float prevY, Mat? queryMatMask = null)
|
||||
{
|
||||
@@ -150,17 +151,18 @@ public class FeatureMatcher
|
||||
Debug.WriteLine($"---------切换到新的特征块({cellRow},{cellCol}),合并特征点--------");
|
||||
_lastMergedBlock = KeyPointFeatureBlockHelper.MergeNeighboringFeatures(_blocks, _trainDescriptors, cellRow, cellCol);
|
||||
}
|
||||
|
||||
return Match(_lastMergedBlock.KeyPointArray, _lastMergedBlock.Descriptor!, queryMat, queryMatMask);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于从训练图像和查询图像中找到匹配的特征点,计算透视变换并确定查询图像的中心点在训练图像中的位置。
|
||||
/// 普通匹配
|
||||
/// </summary>
|
||||
/// <param name="trainKeyPoints">训练图像中的关键点集合。</param>
|
||||
/// <param name="trainDescriptors">训练图像的特征描述子。</param>
|
||||
/// <param name="queryMat">查询图像的 Mat 对象。</param>
|
||||
/// <param name="queryMatMask">查询图像的 Mask,用于限定检测特征的区域。</param>
|
||||
/// <param name="matcherType">描述符匹配器的类型,默认为 DescriptorMatcherType.FlannBased</param>
|
||||
/// <param name="trainKeyPoints"></param>
|
||||
/// <param name="trainDescriptors"></param>
|
||||
/// <param name="queryMat"></param>
|
||||
/// <param name="queryMatMask"></param>
|
||||
/// <param name="matcherType"></param>
|
||||
/// <returns></returns>
|
||||
public Point2f Match(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
public class FeatureStorage(string name)
|
||||
{
|
||||
private readonly string rootPath = Global.Absolute(@"Assets\Map\");
|
||||
|
||||
public void SetType(Feature2DType type)
|
||||
{
|
||||
TypeName = type.ToString();
|
||||
@@ -15,6 +16,24 @@ public class FeatureStorage(string name)
|
||||
|
||||
public string TypeName { get; set; } = "UNKNOWN";
|
||||
|
||||
// public KeyPoint[]? LoadKeyPointArray1()
|
||||
// {
|
||||
// CreateFolder();
|
||||
// string kpPath = Path.Combine(rootPath, $"{name}_{TypeName}.kp");
|
||||
// if (File.Exists(kpPath))
|
||||
// {
|
||||
// return ObjectUtils.Deserialize(File.ReadAllBytes(kpPath)) as KeyPoint[];
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public void SaveKeyPointArray1(KeyPoint[] kpArray)
|
||||
// {
|
||||
// CreateFolder();
|
||||
// string kpPath = Path.Combine(rootPath, $"{name}_{TypeName}.kp");
|
||||
// File.WriteAllBytes(kpPath, ObjectUtils.Serialize(kpArray));
|
||||
// }
|
||||
|
||||
public KeyPoint[]? LoadKeyPointArray()
|
||||
{
|
||||
CreateFolder();
|
||||
@@ -46,6 +65,32 @@ public class FeatureStorage(string name)
|
||||
}
|
||||
}
|
||||
|
||||
// public Mat? LoadDescMat1()
|
||||
// {
|
||||
// CreateFolder();
|
||||
// // 格式: Surf_336767x128.mat
|
||||
// var files = Directory.GetFiles(rootPath, $"{name}_{TypeName}_*.mat", SearchOption.AllDirectories);
|
||||
// if (files.Length == 0)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
// else if (files.Length > 1)
|
||||
// {
|
||||
// Debug.WriteLine($"[FeatureSerializer] Found multiple files: {string.Join(", ", files)}");
|
||||
// }
|
||||
// var rowColPair = Path.GetFileNameWithoutExtension(files[0])
|
||||
// .Replace($"{name}_{TypeName}_", "")
|
||||
// .Split('x');
|
||||
// if (rowColPair.Length != 2)
|
||||
// {
|
||||
// Debug.WriteLine($"[FeatureSerializer] Invalid file name: {files[0]}");
|
||||
// return null;
|
||||
// }
|
||||
// GCHandle pinnedArray = GCHandle.Alloc(ObjectUtils.Deserialize(File.ReadAllBytes(files[0])), GCHandleType.Pinned);
|
||||
// IntPtr pointer = pinnedArray.AddrOfPinnedObject();
|
||||
// return new Mat(Convert.ToInt32(rowColPair[0]), Convert.ToInt32(rowColPair[1]), MatType.CV_32FC1, pointer);
|
||||
// }
|
||||
|
||||
public Mat? LoadDescMat()
|
||||
{
|
||||
CreateFolder();
|
||||
@@ -64,6 +109,22 @@ public class FeatureStorage(string name)
|
||||
return mat;
|
||||
}
|
||||
|
||||
// public void SaveDescMat1(Mat descMat)
|
||||
// {
|
||||
// CreateFolder();
|
||||
// // 删除旧文件
|
||||
// var files = Directory.GetFiles(rootPath, $"{name}_{TypeName}_*.mat", SearchOption.AllDirectories);
|
||||
// foreach (var file in files)
|
||||
// {
|
||||
// File.Delete(file);
|
||||
// }
|
||||
//
|
||||
// var descPath = Path.Combine(rootPath, $"{name}_{TypeName}_{descMat.Rows}x{descMat.Cols}.mat");
|
||||
// var bytes = new byte[descMat.Step(0) * descMat.Rows]; // matSrcRet.Total() * matSrcRet.ElemSize()
|
||||
// Marshal.Copy(descMat.Data, bytes, 0, bytes.Length);
|
||||
// File.WriteAllBytes(descPath, ObjectUtils.Serialize(bytes));
|
||||
// }
|
||||
|
||||
public void SaveDescMat(Mat descMat)
|
||||
{
|
||||
CreateFolder();
|
||||
@@ -74,6 +135,7 @@ public class FeatureStorage(string name)
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
var descPath = Path.Combine(rootPath, fileName);
|
||||
FileStorage fs = new(descPath, FileStorage.Modes.Write);
|
||||
fs.Write("desc", descMat);
|
||||
|
||||
@@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging;
|
||||
using SharpDX.DirectInput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
@@ -115,7 +114,7 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
ra.Dispose();
|
||||
}
|
||||
|
||||
public void GlobalHookKeyDown(KeyEventArgs e, uint time)
|
||||
public void GlobalHookKeyDown(KeyEventArgs e)
|
||||
{
|
||||
// 排除热键
|
||||
if (e.KeyCode.ToString() == TaskContext.Instance().Config.HotKeyConfig.KeyMouseMacroRecordHotkey)
|
||||
@@ -139,10 +138,10 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
_keyDownState.Add(e.KeyCode, true);
|
||||
}
|
||||
// Debug.WriteLine($"KeyDown: {e.KeyCode}");
|
||||
_recorder?.KeyDown(e, time);
|
||||
_recorder?.KeyDown(e);
|
||||
}
|
||||
|
||||
public void GlobalHookKeyUp(KeyEventArgs e, uint time)
|
||||
public void GlobalHookKeyUp(KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode.ToString() == TaskContext.Instance().Config.HotKeyConfig.Test1Hotkey)
|
||||
{
|
||||
@@ -153,7 +152,7 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
{
|
||||
// Debug.WriteLine($"KeyUp: {e.KeyCode}");
|
||||
_keyDownState[e.KeyCode] = false;
|
||||
_recorder?.KeyUp(e, time);
|
||||
_recorder?.KeyUp(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,21 +177,15 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
// Debug.WriteLine($"MouseMove: {e.X}, {e.Y}");
|
||||
_recorder?.MouseMoveTo(e);
|
||||
}
|
||||
|
||||
public void GlobalHookMouseWheel(MouseEventExtArgs e)
|
||||
{
|
||||
// Debug.WriteLine($"MouseWheel: {e.Delta}");
|
||||
_recorder?.MouseWheel(e);
|
||||
}
|
||||
|
||||
public void GlobalHookMouseMoveBy(MouseState state, uint time)
|
||||
public void GlobalHookMouseMoveBy(MouseState state)
|
||||
{
|
||||
if (state is { X: 0, Y: 0 } || !_isInMainUi)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Debug.WriteLine($"MouseMoveBy: {state.X}, {state.Y}");
|
||||
_recorder?.MouseMoveBy(state, time);
|
||||
_recorder?.MouseMoveBy(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Fischless.WindowsInput;
|
||||
using Vanara.PInvoke;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
@@ -49,7 +48,7 @@ public class KeyMouseMacroPlayer
|
||||
public static async Task PlayMacro(List<MacroEvent> macroEvents, CancellationToken ct)
|
||||
{
|
||||
WorkingArea = PrimaryScreen.WorkingArea;
|
||||
var startTime = Kernel32.GetTickCount();
|
||||
var startTime = DateTime.UtcNow;
|
||||
foreach (var e in macroEvents)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
@@ -57,42 +56,23 @@ public class KeyMouseMacroPlayer
|
||||
return;
|
||||
}
|
||||
|
||||
var timeToWait = e.Time - (Kernel32.GetTickCount() - startTime);
|
||||
var timeToWait = (int)(e.Time - (DateTime.UtcNow - startTime).TotalMilliseconds);
|
||||
if (timeToWait < 0)
|
||||
{
|
||||
TaskControl.Logger.LogDebug("无法原速重放事件{Event},落后{TimeToWait}ms", e.Type.ToString(), (-timeToWait).ToString("F0"));
|
||||
TaskControl.Logger.LogWarning("无法原速重放事件{Event},落后{TimeToWait}ms", e.Type.ToString(), -timeToWait);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Task.Delay((int)timeToWait, ct);
|
||||
await Task.Delay(timeToWait, ct);
|
||||
}
|
||||
|
||||
switch (e.Type)
|
||||
{
|
||||
case MacroEventType.KeyDown:
|
||||
var vkDown = (User32.VK)e.KeyCode!;
|
||||
if (InputBuilder.IsExtendedKey(vkDown))
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(false, vkDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(vkDown);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyDown((User32.VK)e.KeyCode!);
|
||||
break;
|
||||
|
||||
case MacroEventType.KeyUp:
|
||||
|
||||
var vkUp = (User32.VK)e.KeyCode!;
|
||||
if (InputBuilder.IsExtendedKey(vkUp))
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(false, vkUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(vkUp);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyUp((User32.VK)e.KeyCode!);
|
||||
break;
|
||||
|
||||
case MacroEventType.MouseDown:
|
||||
@@ -165,16 +145,6 @@ public class KeyMouseMacroPlayer
|
||||
Simulation.SendInput.Mouse.MoveMouseTo(ToVirtualDesktopX(e.MouseX), ToVirtualDesktopY(e.MouseY));
|
||||
break;
|
||||
|
||||
case MacroEventType.MouseWheel:
|
||||
var num = (int)(e.MouseY / 120.0);
|
||||
if (num != 0)
|
||||
{
|
||||
// 不支持多次的场景,但是不会出现这种情况
|
||||
Simulation.SendInput.Mouse.VerticalScroll(num);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MacroEventType.MouseMoveBy:
|
||||
if (e.CameraOrientation != null)
|
||||
{
|
||||
@@ -188,7 +158,6 @@ public class KeyMouseMacroPlayer
|
||||
e.MouseX -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(e.MouseX, e.MouseY);
|
||||
break;
|
||||
|
||||
@@ -209,4 +178,4 @@ public class KeyMouseMacroPlayer
|
||||
{
|
||||
return y * 65535 * 1d / WorkingArea.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
@@ -17,7 +16,7 @@ public class KeyMouseRecorder
|
||||
{
|
||||
public List<MacroEvent> MacroEvents { get; } = [];
|
||||
|
||||
public uint StartTime { get; set; } = Kernel32.GetTickCount();
|
||||
public DateTime StartTime { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public DateTime LastOrientationDetection { get; set; } = DateTime.UtcNow;
|
||||
|
||||
@@ -35,11 +34,6 @@ public class KeyMouseRecorder
|
||||
|
||||
public string ToJsonMacro()
|
||||
{
|
||||
// MacroEvents 需要以实际时间进行排序
|
||||
MacroEvents.Sort((a, b) => a.Time.CompareTo(b.Time));
|
||||
// 删除为负数的时间
|
||||
MacroEvents.RemoveAll(m => m.Time < 0);
|
||||
|
||||
var rect = TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
// 合并鼠标移动事件
|
||||
var mergedMacroEvents = new List<MacroEvent>();
|
||||
@@ -110,23 +104,23 @@ public class KeyMouseRecorder
|
||||
return JsonSerializer.Serialize(keyMouseScript, JsonOptions);
|
||||
}
|
||||
|
||||
public void KeyDown(KeyEventArgs e, uint time)
|
||||
public void KeyDown(KeyEventArgs e)
|
||||
{
|
||||
MacroEvents.Add(new MacroEvent
|
||||
{
|
||||
Type = MacroEventType.KeyDown,
|
||||
KeyCode = e.KeyValue,
|
||||
Time = time - StartTime
|
||||
Time = (DateTime.UtcNow - StartTime).TotalMilliseconds
|
||||
});
|
||||
}
|
||||
|
||||
public void KeyUp(KeyEventArgs e, uint time)
|
||||
public void KeyUp(KeyEventArgs e)
|
||||
{
|
||||
MacroEvents.Add(new MacroEvent
|
||||
{
|
||||
Type = MacroEventType.KeyUp,
|
||||
KeyCode = e.KeyValue,
|
||||
Time = time - StartTime
|
||||
Time = (DateTime.UtcNow - StartTime).TotalMilliseconds
|
||||
});
|
||||
}
|
||||
|
||||
@@ -138,7 +132,7 @@ public class KeyMouseRecorder
|
||||
MouseX = e.X,
|
||||
MouseY = e.Y,
|
||||
MouseButton = e.Button.ToString(),
|
||||
Time = e.Timestamp - StartTime
|
||||
Time = (DateTime.UtcNow - StartTime).TotalMilliseconds
|
||||
});
|
||||
}
|
||||
|
||||
@@ -150,7 +144,7 @@ public class KeyMouseRecorder
|
||||
MouseX = e.X,
|
||||
MouseY = e.Y,
|
||||
MouseButton = e.Button.ToString(),
|
||||
Time = e.Timestamp - StartTime
|
||||
Time = (DateTime.UtcNow - StartTime).TotalMilliseconds
|
||||
});
|
||||
}
|
||||
|
||||
@@ -161,40 +155,28 @@ public class KeyMouseRecorder
|
||||
Type = MacroEventType.MouseMoveTo,
|
||||
MouseX = e.X,
|
||||
MouseY = e.Y,
|
||||
Time = e.Timestamp - StartTime
|
||||
});
|
||||
}
|
||||
|
||||
public void MouseWheel(MouseEventExtArgs e)
|
||||
{
|
||||
MacroEvents.Add(new MacroEvent
|
||||
{
|
||||
Type = MacroEventType.MouseWheel,
|
||||
MouseY = e.Delta, // 120 的倍率
|
||||
Time = e.Timestamp - StartTime
|
||||
Time = (DateTime.UtcNow - StartTime).TotalMilliseconds
|
||||
});
|
||||
}
|
||||
|
||||
public void MouseMoveBy(MouseState state, uint time)
|
||||
public void MouseMoveBy(MouseState state)
|
||||
{
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
int? cao = null;
|
||||
if (TaskContext.Instance().Config.RecordConfig.IsRecordCameraOrientation)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if ((now - LastOrientationDetection).TotalMilliseconds > 100.0)
|
||||
{
|
||||
LastOrientationDetection = now;
|
||||
cao = (int)Math.Round(CameraOrientation.Compute(TaskControl.CaptureToRectArea().SrcMat));
|
||||
}
|
||||
}
|
||||
|
||||
MacroEvents.Add(new MacroEvent
|
||||
{
|
||||
Type = MacroEventType.MouseMoveBy,
|
||||
MouseX = state.X,
|
||||
MouseY = state.Y,
|
||||
Time = time - 5 - StartTime,
|
||||
Time = (now - StartTime).TotalMilliseconds,
|
||||
CameraOrientation = cao,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,5 @@ public enum MacroEventType
|
||||
MouseMoveTo,
|
||||
MouseMoveBy,
|
||||
MouseDown,
|
||||
MouseUp,
|
||||
MouseWheel
|
||||
MouseUp
|
||||
}
|
||||
@@ -5,29 +5,17 @@ using BetterGenshinImpact.Core.Config;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
public class AutoPathingScript
|
||||
public class AutoPathingScript(string rootPath)
|
||||
{
|
||||
private object? _config = null;
|
||||
private string _rootPath;
|
||||
public AutoPathingScript(string rootPath, object? config) {
|
||||
|
||||
_config = config;
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
public async Task Run(string json)
|
||||
{
|
||||
var task = PathingTask.BuildFromJson(json);
|
||||
var pathExecutor = new PathExecutor(CancellationContext.Instance.Cts.Token);
|
||||
if (_config != null && _config is PathingPartyConfig patyConfig ) {
|
||||
pathExecutor.PartyConfig = patyConfig;
|
||||
}
|
||||
await pathExecutor.Pathing(task);
|
||||
await new PathExecutor(CancellationContext.Instance.Cts.Token).Pathing(task);
|
||||
}
|
||||
|
||||
public async Task RunFile(string path)
|
||||
{
|
||||
var json = await new LimitedFile(_rootPath).ReadText(path);
|
||||
var json = await new LimitedFile(rootPath).ReadText(path);
|
||||
await Run(json);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,11 @@ using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
public class Dispatcher
|
||||
{
|
||||
private object _config=null;
|
||||
public Dispatcher(object config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
public void RunTask()
|
||||
{
|
||||
}
|
||||
@@ -83,15 +77,17 @@ public class Dispatcher
|
||||
break;
|
||||
|
||||
case "AutoFight":
|
||||
|
||||
/*if (taskSettingsPageViewModel.GetFightStrategy(out var path1))
|
||||
if (taskSettingsPageViewModel.GetFightStrategy(out var path1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var autoFightConfig = TaskContext.Instance().Config.AutoFightConfig;
|
||||
var param = new AutoFightParam(path1, autoFightConfig);
|
||||
await new AutoFightTask(param).Start(CancellationContext.Instance.Cts.Token);*/
|
||||
await new AutoFightHandler().RunAsyncByScript(CancellationContext.Instance.Cts.Token, null,_config);
|
||||
var param = new AutoFightParam(path1)
|
||||
{
|
||||
FightFinishDetectEnabled = autoFightConfig.FightFinishDetectEnabled,
|
||||
PickDropsAfterFightEnabled = autoFightConfig.PickDropsAfterFightEnabled
|
||||
};
|
||||
await new AutoFightTask(param).Start(CancellationContext.Instance.Cts.Token);
|
||||
break;
|
||||
|
||||
case "AutoDomain":
|
||||
|
||||
@@ -6,7 +6,6 @@ using System;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Vanara.PInvoke;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
@@ -21,77 +20,17 @@ public class GlobalMethod
|
||||
|
||||
public static void KeyDown(string key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonDown();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyDown(ToVk(key));
|
||||
break;
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyDown(ToVk(key));
|
||||
}
|
||||
|
||||
public static void KeyUp(string key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyUp(ToVk(key));
|
||||
break;
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyUp(ToVk(key));
|
||||
}
|
||||
|
||||
public static void KeyPress(string key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonClick();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyPress(ToVk(key));
|
||||
break;
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyPress(ToVk(key));
|
||||
}
|
||||
|
||||
private static User32.VK ToVk(string key)
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using OpenCvSharp;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script;
|
||||
|
||||
@@ -18,19 +17,19 @@ public class EngineExtend
|
||||
/// <param name="engine"></param>
|
||||
/// <param name="workDir"></param>
|
||||
/// <param name="searchPaths"></param>
|
||||
public static void InitHost(IScriptEngine engine, string workDir, string[]? searchPaths = null, object? config = null)
|
||||
public static void InitHost(IScriptEngine engine, string workDir, string[]? searchPaths = null)
|
||||
{
|
||||
// engine.AddHostObject("xHost", new ExtendedHostFunctions()); // 有越权的安全风险
|
||||
|
||||
// 添加我的自定义实例化对象
|
||||
engine.AddHostObject("keyMouseScript", new KeyMouseScript(workDir));
|
||||
engine.AddHostObject("pathingScript", new AutoPathingScript(workDir, config));
|
||||
engine.AddHostObject("pathingScript", new AutoPathingScript(workDir));
|
||||
engine.AddHostObject("genshin", new Dependence.Genshin());
|
||||
engine.AddHostObject("log", new Log());
|
||||
engine.AddHostObject("file", new LimitedFile(workDir)); // 限制文件访问
|
||||
|
||||
// 任务调度器
|
||||
engine.AddHostObject("dispatcher", new Dispatcher(config));
|
||||
engine.AddHostObject("dispatcher", new Dispatcher());
|
||||
engine.AddHostType("RealtimeTimer", typeof(RealtimeTimer));
|
||||
engine.AddHostType("SoloTask", typeof(SoloTask));
|
||||
|
||||
|
||||
@@ -62,7 +62,6 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
[JsonIgnore]
|
||||
public ScriptProject? Project { get; set; }
|
||||
|
||||
|
||||
public ExpandoObject? JsScriptSettingsObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -70,12 +69,6 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ScriptGroup? GroupInfo { get; set; }
|
||||
/// <summary>
|
||||
/// 下一个从此执行标志
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[ObservableProperty]
|
||||
public bool? _nextFlag = false;
|
||||
|
||||
public ScriptGroupProject()
|
||||
{
|
||||
@@ -138,14 +131,7 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
throw new Exception("JS脚本未初始化");
|
||||
}
|
||||
JsScriptSettingsObject ??= new ExpandoObject();
|
||||
|
||||
var pathingPartyConfig = GroupInfo?.Config.PathingConfig;
|
||||
if (!(pathingPartyConfig is {Enabled:true,JsScriptUseEnabled:true}))
|
||||
{
|
||||
pathingPartyConfig = null;
|
||||
}
|
||||
|
||||
await Project.ExecuteAsync(JsScriptSettingsObject,pathingPartyConfig);
|
||||
await Project.ExecuteAsync(JsScriptSettingsObject);
|
||||
}
|
||||
if (Type == "KeyMouse")
|
||||
{
|
||||
|
||||
@@ -57,20 +57,20 @@ public class ScriptProject
|
||||
return stackPanel;
|
||||
}
|
||||
|
||||
public IScriptEngine BuildScriptEngine(PathingPartyConfig? partyConfig = null)
|
||||
public IScriptEngine BuildScriptEngine()
|
||||
{
|
||||
IScriptEngine engine = new V8ScriptEngine(V8ScriptEngineFlags.UseCaseInsensitiveMemberBinding | V8ScriptEngineFlags.EnableTaskPromiseConversion);
|
||||
EngineExtend.InitHost(engine, ProjectPath, Manifest.Library,partyConfig);
|
||||
EngineExtend.InitHost(engine, ProjectPath, Manifest.Library);
|
||||
return engine;
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync(dynamic? context = null, PathingPartyConfig? partyConfig=null)
|
||||
public async Task ExecuteAsync(dynamic? context = null)
|
||||
{
|
||||
// 默认值
|
||||
GlobalMethod.SetGameMetrics(1920, 1080);
|
||||
// 加载代码
|
||||
var code = await LoadCode();
|
||||
var engine = BuildScriptEngine(partyConfig);
|
||||
var engine = BuildScriptEngine();
|
||||
if (context != null)
|
||||
{
|
||||
// 写入配置的内容
|
||||
|
||||
@@ -35,11 +35,7 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
public static readonly string ReposTempPath = Path.Combine(ReposPath, "Temp");
|
||||
|
||||
// 中央仓库信息地址
|
||||
public static readonly List<string> CenterRepoInfoUrls =
|
||||
[
|
||||
"https://raw.githubusercontent.com/babalae/bettergi-scripts-list/refs/heads/main/repo.json",
|
||||
"https://r2-script.bettergi.com/github_mirror/repo.json",
|
||||
];
|
||||
public static readonly string CenterRepoInfoUrl = "https://raw.githubusercontent.com/babalae/bettergi-scripts-list/refs/heads/main/repo.json";
|
||||
|
||||
// 中央仓库解压后文件夹名
|
||||
public static readonly string CenterRepoUnzipName = "bettergi-scripts-list-main";
|
||||
@@ -92,12 +88,10 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
public async Task<(string, bool)> UpdateCenterRepo()
|
||||
{
|
||||
// 测速并获取信息
|
||||
var (fastUrl, jsonString) = await ProxySpeedTester.GetFastestUrlAsync(CenterRepoInfoUrls);
|
||||
if (string.IsNullOrEmpty(jsonString))
|
||||
{
|
||||
throw new Exception("从互联网下载最新的仓库信息失败");
|
||||
}
|
||||
|
||||
var res = await ProxySpeedTester.GetFastestProxyAsync(CenterRepoInfoUrl);
|
||||
// 解析信息
|
||||
var fastProxyUrl = res.Item1;
|
||||
var jsonString = res.Item2;
|
||||
var (time, url, file) = ParseJson(jsonString);
|
||||
|
||||
var updated = false;
|
||||
@@ -116,10 +110,9 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
{
|
||||
needDownload = true;
|
||||
}
|
||||
|
||||
if (needDownload)
|
||||
{
|
||||
await DownloadRepoAndUnzip(url);
|
||||
await DownloadRepoAndUnzip(string.Format(fastProxyUrl, url));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
@@ -135,7 +128,7 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
// 检查是否需要更新
|
||||
if (long.Parse(time) > long.Parse(time2))
|
||||
{
|
||||
await DownloadRepoAndUnzip(url2);
|
||||
await DownloadRepoAndUnzip(string.Format(fastProxyUrl, url2));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
@@ -253,7 +246,6 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
Content = $"检测到{(formClipboard ? "剪切板上存在" : "")}脚本订阅链接,解析后需要导入的脚本为:{pathJson}。\n是否导入并覆盖此文件或者文件夹下的脚本?",
|
||||
CloseButtonText = "关闭",
|
||||
PrimaryButtonText = "确认导入",
|
||||
Owner = Application.Current.MainWindow,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
};
|
||||
|
||||
@@ -324,31 +316,7 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
Toast.Information("获取最新仓库信息中...");
|
||||
|
||||
// 更新仓库
|
||||
string repoPath;
|
||||
try
|
||||
{
|
||||
(repoPath, _) = await Task.Run(UpdateCenterRepo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Toast.Warning("获取最新仓库信息失败,尝试使用本地已有仓库信息");
|
||||
try
|
||||
{
|
||||
repoPath = FindCenterRepoPath();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await MessageBox.ErrorAsync("本地无仓库信息,请至少成功更新一次脚本仓库信息!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(repoPath))
|
||||
{
|
||||
await MessageBox.ErrorAsync("本地无仓库信息,请至少成功更新一次脚本仓库信息!");
|
||||
return;
|
||||
}
|
||||
|
||||
var (repoPath, _) = await Task.Run(UpdateCenterRepo);
|
||||
|
||||
// // 收集将被覆盖的文件和文件夹
|
||||
// var filesToOverwrite = new List<string>();
|
||||
@@ -423,9 +391,6 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
}
|
||||
else if (File.Exists(scriptPath))
|
||||
{
|
||||
// 目标文件所在文件夹不存在时创建它
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destPath)!);
|
||||
|
||||
if (File.Exists(destPath))
|
||||
{
|
||||
File.Delete(destPath);
|
||||
@@ -486,7 +451,7 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
{
|
||||
_webWindow = new WebpageWindow
|
||||
{
|
||||
Title = "Genshin Copilot Scripts | BetterGI 脚本本地中央仓库",
|
||||
Title = "enshin Copilot Scripts | BetterGI 脚本本地中央仓库",
|
||||
Width = 1366,
|
||||
Height = 768,
|
||||
};
|
||||
@@ -522,4 +487,4 @@ public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using System.Security.Policy;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.ViewModel.Message;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.WebView;
|
||||
|
||||
@@ -22,32 +21,39 @@ public class RepoWebBridge
|
||||
{
|
||||
try
|
||||
{
|
||||
await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Toast.Warning($"更新仓库信息失败:{e.Message}");
|
||||
}
|
||||
// var needUpdate = false;
|
||||
// string? localRepoJsonPath = null;
|
||||
// if (Directory.Exists(ScriptRepoUpdater.CenterRepoPath))
|
||||
// {
|
||||
// localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
// if (localRepoJsonPath is null)
|
||||
// {
|
||||
// needUpdate = true;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// needUpdate = true;
|
||||
// }
|
||||
//
|
||||
// if (needUpdate)
|
||||
// {
|
||||
// await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(ScriptRepoUpdater.CenterRepoPath))
|
||||
{
|
||||
throw new Exception("仓库文件夹不存在,请至少成功更新一次仓库!");
|
||||
}
|
||||
await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
||||
|
||||
var localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (localRepoJsonPath is null)
|
||||
{
|
||||
throw new Exception("repo.json 仓库索引文件不存在,请至少成功更新一次仓库!");
|
||||
throw new Exception("repo.json 不存在,可能是更新仓库信息失败!");
|
||||
}
|
||||
|
||||
var json = await File.ReadAllTextAsync(localRepoJsonPath);
|
||||
return json;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await MessageBox.ShowAsync(e.Message, "获取仓库信息失败");
|
||||
await MessageBox.ShowAsync(e.Message, "获取仓库信息失败!");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -64,4 +70,4 @@ public class RepoWebBridge
|
||||
await MessageBox.ShowAsync(e.Message, "订阅脚本链接失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟按键类型
|
||||
/// </summary>
|
||||
public enum KeyType
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 单击按键(KeyPress)
|
||||
/// </summary>
|
||||
KeyPress,
|
||||
|
||||
/// <summary>
|
||||
/// 按住按键(KeyDown)
|
||||
/// </summary>
|
||||
KeyDown,
|
||||
|
||||
/// <summary>
|
||||
/// 释放按键(KeyUp)
|
||||
/// </summary>
|
||||
KeyUp,
|
||||
|
||||
/// <summary>
|
||||
/// 长按1s
|
||||
/// </summary>
|
||||
Hold,
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 原神按键动作
|
||||
/// </summary>
|
||||
public enum GIActions
|
||||
{
|
||||
/// <summary>
|
||||
/// 向前移动
|
||||
/// </summary>
|
||||
MoveForward,
|
||||
|
||||
/// <summary>
|
||||
/// 向后移动
|
||||
/// </summary>
|
||||
MoveBackward,
|
||||
|
||||
/// <summary>
|
||||
/// 向左移动
|
||||
/// </summary>
|
||||
MoveLeft,
|
||||
|
||||
/// <summary>
|
||||
/// 向右移动
|
||||
/// </summary>
|
||||
MoveRight,
|
||||
|
||||
/// <summary>
|
||||
/// 切换走/跑;特定操作模式下向下移动
|
||||
/// </summary>
|
||||
SwitchToWalkOrRun,
|
||||
|
||||
/// <summary>
|
||||
/// 普通攻击
|
||||
/// </summary>
|
||||
NormalAttack,
|
||||
|
||||
/// <summary>
|
||||
/// 元素战技
|
||||
/// </summary>
|
||||
ElementalSkill,
|
||||
|
||||
/// <summary>
|
||||
/// 元素爆发
|
||||
/// </summary>
|
||||
ElementalBurst,
|
||||
|
||||
/// <summary>
|
||||
/// 冲刺(键盘)
|
||||
/// </summary>
|
||||
SprintKeyboard,
|
||||
|
||||
/// <summary>
|
||||
/// 冲刺(鼠标)
|
||||
/// </summary>
|
||||
SprintMouse,
|
||||
|
||||
/// <summary>
|
||||
/// 切换瞄准模式
|
||||
/// </summary>
|
||||
SwitchAimingMode,
|
||||
|
||||
/// <summary>
|
||||
/// 跳跃;特定操作模式下向上移动
|
||||
/// </summary>
|
||||
Jump,
|
||||
|
||||
/// <summary>
|
||||
/// 落下
|
||||
/// </summary>
|
||||
Drop,
|
||||
|
||||
/// <summary>
|
||||
/// 拾取/交互(自动拾取由AutoPick模块管理)
|
||||
/// </summary>
|
||||
PickUpOrInteract,
|
||||
|
||||
/// <summary>
|
||||
/// 快捷使用小道具
|
||||
/// </summary>
|
||||
QuickUseGadget,
|
||||
|
||||
/// <summary>
|
||||
/// 特定玩法内交互操作
|
||||
/// </summary>
|
||||
InteractionInSomeMode,
|
||||
|
||||
/// <summary>
|
||||
/// 开启任务追踪
|
||||
/// </summary>
|
||||
QuestNavigation,
|
||||
|
||||
/// <summary>
|
||||
/// 中断挑战
|
||||
/// </summary>
|
||||
AbandonChallenge,
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色1
|
||||
/// </summary>
|
||||
SwitchMember1,
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色2
|
||||
/// </summary>
|
||||
SwitchMember2,
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色3
|
||||
/// </summary>
|
||||
SwitchMember3,
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色4
|
||||
/// </summary>
|
||||
SwitchMember4,
|
||||
|
||||
/// <summary>
|
||||
/// 切换小队角色5
|
||||
/// </summary>
|
||||
SwitchMember5,
|
||||
|
||||
/// <summary>
|
||||
/// 呼出快捷轮盘
|
||||
/// </summary>
|
||||
ShortcutWheel,
|
||||
|
||||
/// <summary>
|
||||
/// 打开背包
|
||||
/// </summary>
|
||||
OpenInventory,
|
||||
|
||||
/// <summary>
|
||||
/// 打开角色界面
|
||||
/// </summary>
|
||||
OpenCharacterScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开地图
|
||||
/// </summary>
|
||||
OpenMap,
|
||||
|
||||
/// <summary>
|
||||
/// 打开派蒙界面
|
||||
/// </summary>
|
||||
OpenPaimonMenu,
|
||||
|
||||
/// <summary>
|
||||
/// 打开冒险之证界面
|
||||
/// </summary>
|
||||
OpenAdventurerHandbook,
|
||||
|
||||
/// <summary>
|
||||
/// 打开多人游戏界面
|
||||
/// </summary>
|
||||
OpenCoOpScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开祈愿界面
|
||||
/// </summary>
|
||||
OpenWishScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开纪行界面
|
||||
/// </summary>
|
||||
OpenBattlePassScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开活动面板
|
||||
/// </summary>
|
||||
OpenTheEventsMenu,
|
||||
|
||||
/// <summary>
|
||||
/// 打开玩法系统界面(尘歌壶内猫尾酒馆内)
|
||||
/// </summary>
|
||||
OpenTheSettingsMenu,
|
||||
|
||||
/// <summary>
|
||||
/// 打开摆设界面(尘歌壶内)
|
||||
/// </summary>
|
||||
OpenTheFurnishingScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开星之归还(条件符合期间生效)
|
||||
/// </summary>
|
||||
OpenStellarReunion,
|
||||
|
||||
/// <summary>
|
||||
/// 开关任务菜单
|
||||
/// </summary>
|
||||
OpenQuestMenu,
|
||||
|
||||
/// <summary>
|
||||
/// 打开通知详情
|
||||
/// </summary>
|
||||
OpenNotificationDetails,
|
||||
|
||||
/// <summary>
|
||||
/// 打开聊天界面
|
||||
/// </summary>
|
||||
OpenChatScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开特殊环境说明
|
||||
/// </summary>
|
||||
OpenSpecialEnvironmentInformation,
|
||||
|
||||
/// <summary>
|
||||
/// 查看教程详情
|
||||
/// </summary>
|
||||
CheckTutorialDetails,
|
||||
|
||||
/// <summary>
|
||||
/// 长按打开元素视野
|
||||
/// </summary>
|
||||
ElementalSight,
|
||||
|
||||
/// <summary>
|
||||
/// 呼出鼠标
|
||||
/// </summary>
|
||||
ShowCursor,
|
||||
|
||||
/// <summary>
|
||||
/// 打开队伍配置界面
|
||||
/// </summary>
|
||||
OpenPartySetupScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 打开好友界面
|
||||
/// </summary>
|
||||
OpenFriendsScreen,
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏主界面
|
||||
/// </summary>
|
||||
HideUI,
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using System.Threading;
|
||||
using Fischless.WindowsInput;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// 用于扩展<seealso cref="Fischless.WindowsInput.InputSimulator"/>的功能
|
||||
/// </summary>
|
||||
public static class InputSimulatorExtension
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 模拟玩家操作
|
||||
/// </summary>
|
||||
/// <param name="action">动作</param>
|
||||
/// <param name="type">按键类型</param>
|
||||
public static void SimulateAction(this InputSimulator self, GIActions action, KeyType type = KeyType.KeyPress)
|
||||
{
|
||||
var key = action.ToActionKey();
|
||||
switch (type)
|
||||
{
|
||||
case KeyType.KeyPress:
|
||||
KeyPress(self, key);
|
||||
break;
|
||||
case KeyType.KeyDown:
|
||||
KeyDown(self, key);
|
||||
break;
|
||||
case KeyType.KeyUp:
|
||||
KeyUp(self, key);
|
||||
break;
|
||||
case KeyType.Hold:
|
||||
HoldKeyPress(self, key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void HoldKeyPress(InputSimulator self, KeyId key)
|
||||
{
|
||||
KeyDown(self, key);
|
||||
Thread.Sleep(1000);
|
||||
KeyUp(self, key);
|
||||
}
|
||||
|
||||
private static void KeyPress(InputSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.Mouse.LeftButtonClick();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.Mouse.RightButtonClick();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
self.Mouse.MiddleButtonClick();
|
||||
break;
|
||||
case KeyId.MouseSideButton1:
|
||||
self.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
case KeyId.MouseSideButton2:
|
||||
self.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
default:
|
||||
self.Keyboard.KeyPress(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyDown(InputSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.Mouse.LeftButtonDown();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.Mouse.RightButtonDown();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
self.Mouse.MiddleButtonDown();
|
||||
break;
|
||||
case KeyId.MouseSideButton1:
|
||||
self.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
case KeyId.MouseSideButton2:
|
||||
self.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
default:
|
||||
self.Keyboard.KeyDown(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyUp(InputSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.Mouse.LeftButtonUp();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.Mouse.RightButtonUp();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
self.Mouse.MiddleButtonUp();
|
||||
break;
|
||||
case KeyId.MouseSideButton1:
|
||||
self.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
case KeyId.MouseSideButton2:
|
||||
self.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
default:
|
||||
self.Keyboard.KeyUp(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using Fischless.WindowsInput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// 为<seealso cref="PostMessageSimulator"/>提供扩展功能
|
||||
/// </summary>
|
||||
public static class PostMessageSimulatorExtension
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 模拟玩家操作
|
||||
/// </summary>
|
||||
/// <param name="action">动作</param>
|
||||
/// <param name="type">按键类型</param>
|
||||
public static PostMessageSimulator SimulateAction(this PostMessageSimulator self, GIActions action, KeyType type = KeyType.KeyPress)
|
||||
{
|
||||
var key = action.ToActionKey();
|
||||
switch (type)
|
||||
{
|
||||
case KeyType.KeyPress:
|
||||
KeyPress(self, key);
|
||||
break;
|
||||
case KeyType.KeyDown:
|
||||
KeyDown(self, key);
|
||||
break;
|
||||
case KeyType.KeyUp:
|
||||
KeyUp(self, key);
|
||||
break;
|
||||
case KeyType.Hold:
|
||||
HoldKeyPress(self, key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
private static void HoldKeyPress(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
self.LongKeyPress(key.ToVK());
|
||||
}
|
||||
|
||||
private static void KeyPress(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.LeftButtonClick();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.RightButtonClick();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyPress(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyDown(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.LeftButtonDown();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.RightButtonDown();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyDown(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyUp(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.LeftButtonUp();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
self.RightButtonUp();
|
||||
break;
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyUp(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟玩家操作(后台)
|
||||
/// </summary>
|
||||
/// <param name="action">动作</param>
|
||||
/// <param name="type">按键类型</param>
|
||||
public static PostMessageSimulator SimulateActionBackground(this PostMessageSimulator self, GIActions action, KeyType type = KeyType.KeyPress)
|
||||
{
|
||||
var key = action.ToActionKey();
|
||||
switch (type)
|
||||
{
|
||||
case KeyType.KeyPress:
|
||||
KeyPressBackground(self, key);
|
||||
break;
|
||||
case KeyType.KeyDown:
|
||||
KeyDownBackground(self, key);
|
||||
break;
|
||||
case KeyType.KeyUp:
|
||||
KeyUpBackground(self, key);
|
||||
break;
|
||||
case KeyType.Hold:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
private static void KeyPressBackground(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
self.LeftButtonClickBackground();
|
||||
break;
|
||||
case KeyId.MouseRightButton:
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyPressBackground(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyDownBackground(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
case KeyId.MouseRightButton:
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyDownBackground(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void KeyUpBackground(PostMessageSimulator self, KeyId key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case KeyId.None:
|
||||
case KeyId.Unknown:
|
||||
break;
|
||||
case KeyId.MouseLeftButton:
|
||||
case KeyId.MouseRightButton:
|
||||
case KeyId.MouseMiddleButton:
|
||||
case KeyId.MouseSideButton1:
|
||||
case KeyId.MouseSideButton2:
|
||||
break;
|
||||
default:
|
||||
self.KeyUpBackground(key.ToVK());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
public static class SimulateKeyHelper
|
||||
{
|
||||
|
||||
private static KeyBindingsConfig KeyConfig => TaskContext.Instance().Config.KeyBindingsConfig;
|
||||
|
||||
public static KeyId ToActionKey(this GIActions action)
|
||||
{
|
||||
return GetActionKey(action);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过ActionId取得实际的键盘绑定
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public static KeyId GetActionKey(GIActions action)
|
||||
{
|
||||
return action switch
|
||||
{
|
||||
GIActions.MoveForward => KeyConfig.MoveForward,
|
||||
GIActions.MoveBackward => KeyConfig.MoveBackward,
|
||||
GIActions.MoveLeft => KeyConfig.MoveLeft,
|
||||
GIActions.MoveRight => KeyConfig.MoveRight,
|
||||
GIActions.SwitchToWalkOrRun => KeyConfig.SwitchToWalkOrRun,
|
||||
GIActions.NormalAttack => KeyConfig.NormalAttack,
|
||||
GIActions.ElementalSkill => KeyConfig.ElementalSkill,
|
||||
GIActions.ElementalBurst => KeyConfig.ElementalBurst,
|
||||
GIActions.SprintKeyboard => KeyConfig.SprintKeyboard,
|
||||
GIActions.SprintMouse => KeyConfig.SprintMouse,
|
||||
GIActions.SwitchAimingMode => KeyConfig.SwitchAimingMode,
|
||||
GIActions.Jump => KeyConfig.Jump,
|
||||
GIActions.Drop => KeyConfig.Drop,
|
||||
GIActions.PickUpOrInteract => KeyConfig.PickUpOrInteract,
|
||||
GIActions.QuickUseGadget => KeyConfig.QuickUseGadget,
|
||||
GIActions.InteractionInSomeMode => KeyConfig.InteractionInSomeMode,
|
||||
GIActions.QuestNavigation => KeyConfig.QuestNavigation,
|
||||
GIActions.AbandonChallenge => KeyConfig.AbandonChallenge,
|
||||
GIActions.SwitchMember1 => KeyConfig.SwitchMember1,
|
||||
GIActions.SwitchMember2 => KeyConfig.SwitchMember2,
|
||||
GIActions.SwitchMember3 => KeyConfig.SwitchMember3,
|
||||
GIActions.SwitchMember4 => KeyConfig.SwitchMember4,
|
||||
GIActions.SwitchMember5 => KeyConfig.SwitchMember5,
|
||||
GIActions.ShortcutWheel => KeyConfig.ShortcutWheel,
|
||||
GIActions.OpenInventory => KeyConfig.OpenInventory,
|
||||
GIActions.OpenCharacterScreen => KeyConfig.OpenCharacterScreen,
|
||||
GIActions.OpenMap => KeyConfig.OpenMap,
|
||||
GIActions.OpenPaimonMenu => KeyConfig.OpenPaimonMenu,
|
||||
GIActions.OpenAdventurerHandbook => KeyConfig.OpenAdventurerHandbook,
|
||||
GIActions.OpenCoOpScreen => KeyConfig.OpenCoOpScreen,
|
||||
GIActions.OpenWishScreen => KeyConfig.OpenWishScreen,
|
||||
GIActions.OpenBattlePassScreen => KeyConfig.OpenBattlePassScreen,
|
||||
GIActions.OpenTheEventsMenu => KeyConfig.OpenTheEventsMenu,
|
||||
GIActions.OpenTheSettingsMenu => KeyConfig.OpenTheSettingsMenu,
|
||||
GIActions.OpenTheFurnishingScreen => KeyConfig.OpenTheFurnishingScreen,
|
||||
GIActions.OpenStellarReunion => KeyConfig.OpenStellarReunion,
|
||||
GIActions.OpenQuestMenu => KeyConfig.OpenQuestMenu,
|
||||
GIActions.OpenNotificationDetails => KeyConfig.OpenNotificationDetails,
|
||||
GIActions.OpenChatScreen => KeyConfig.OpenChatScreen,
|
||||
GIActions.OpenSpecialEnvironmentInformation => KeyConfig.OpenSpecialEnvironmentInformation,
|
||||
GIActions.CheckTutorialDetails => KeyConfig.CheckTutorialDetails,
|
||||
GIActions.ElementalSight => KeyConfig.ElementalSight,
|
||||
GIActions.ShowCursor => KeyConfig.ShowCursor,
|
||||
GIActions.OpenPartySetupScreen => KeyConfig.OpenPartySetupScreen,
|
||||
GIActions.OpenFriendsScreen => KeyConfig.OpenFriendsScreen,
|
||||
GIActions.HideUI => KeyConfig.HideUI,
|
||||
_ => default,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
using Fischless.WindowsInput;
|
||||
using System;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Simulator;
|
||||
|
||||
@@ -16,26 +13,4 @@ public class Simulation
|
||||
{
|
||||
return new PostMessageSimulator(hWnd);
|
||||
}
|
||||
|
||||
public static void ReleaseAllKey()
|
||||
{
|
||||
foreach (User32.VK key in Enum.GetValues(typeof(User32.VK)))
|
||||
{
|
||||
// 检查键是否被按下
|
||||
if (IsKeyDown(key)) // 强制转换 VK 枚举为 int
|
||||
{
|
||||
TaskControl.Logger.LogDebug($"解除{key}的按下状态.");
|
||||
SendInput.Keyboard.KeyUp(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsKeyDown(User32.VK key)
|
||||
{
|
||||
// 获取按键状态
|
||||
var state = User32.GetAsyncKeyState((int)key);
|
||||
|
||||
// 检查高位是否为 1(表示按键被按下)
|
||||
return (state & 0x8000) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public partial class AutoDomainConfig : ObservableObject
|
||||
/// 寻找古树时,短距离移动,用于识别速度过慢的计算机使用
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _walkToF = true;
|
||||
private bool _walkToF = false;
|
||||
|
||||
/// <summary>
|
||||
/// 寻找古树时,短距离移动的次数
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
@@ -30,7 +29,6 @@ using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.Kernel32;
|
||||
@@ -44,6 +42,8 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
private readonly AutoDomainParam _taskParam;
|
||||
|
||||
private readonly PostMessageSimulator _simulator;
|
||||
|
||||
private readonly YoloV8Predictor _predictor;
|
||||
|
||||
private readonly AutoDomainConfig _config;
|
||||
@@ -54,8 +54,9 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
public AutoDomainTask(AutoDomainParam taskParam)
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
_taskParam = taskParam;
|
||||
_simulator = AutoFightContext.Instance.Simulator;
|
||||
|
||||
_predictor = YoloV8Builder.CreateDefaultBuilder()
|
||||
.UseOnnxModel(Global.Absolute(@"Assets\Model\Domain\bgi_tree.onnx"))
|
||||
.WithSessionOptions(BgiSessionOption.Instance.Options)
|
||||
@@ -70,45 +71,10 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
_ct = ct;
|
||||
|
||||
AutoFightAssets.DestroyInstance();
|
||||
Init();
|
||||
Notify.Event(NotificationEvent.DomainStart).Success("自动秘境启动");
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build()); // TODO: 通知后续需要删除迁移
|
||||
|
||||
// 3次复活重试
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
await DoDomain();
|
||||
// 其他场景不重试
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.Message.Contains("复活") && !string.IsNullOrEmpty(_taskParam.DomainName))
|
||||
{
|
||||
Logger.LogWarning("自动秘境:{Text}", "复活后重试秘境...");
|
||||
await Delay(2000, ct);
|
||||
Notify.Event(NotificationEvent.DomainRetry).Error("存在角色死亡,复活后重试秘境...");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
await Delay(2000, ct);
|
||||
await Bv.WaitForMainUi(_ct, 30);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await ArtifactSalvage();
|
||||
Notify.Event(NotificationEvent.DomainEnd).Success("自动秘境结束");
|
||||
}
|
||||
|
||||
private async Task DoDomain()
|
||||
{
|
||||
// 传送到秘境
|
||||
await TpDomain();
|
||||
// 切换队伍
|
||||
@@ -117,13 +83,13 @@ public class AutoDomainTask : ISoloTask
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
|
||||
// 前置进入秘境
|
||||
await EnterDomain();
|
||||
EnterDomain();
|
||||
|
||||
for (var i = 0; i < _taskParam.DomainRoundNum; i++)
|
||||
{
|
||||
// 0. 关闭秘境提示
|
||||
Logger.LogDebug("0. 关闭秘境提示");
|
||||
await CloseDomainTip();
|
||||
CloseDomainTip();
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
RetryTeamInit(combatScenes);
|
||||
@@ -160,11 +126,19 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
Logger.LogInformation("体力已经耗尽,结束自动秘境");
|
||||
}
|
||||
|
||||
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Success().Build());
|
||||
break;
|
||||
}
|
||||
Notify.Event(NotificationEvent.DomainReward).Success("自动秘境奖励领取");
|
||||
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
|
||||
}
|
||||
|
||||
await Delay(2000, ct);
|
||||
await Bv.WaitForMainUi(_ct, 30);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await ArtifactSalvage();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
@@ -186,7 +160,6 @@ public class AutoDomainTask : ISoloTask
|
||||
if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
|
||||
{
|
||||
Logger.LogError("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏无法正常使用自动秘境功能 !", gameScreenSize.Width, gameScreenSize.Height);
|
||||
throw new Exception("游戏窗口分辨率不是 16:9");
|
||||
}
|
||||
|
||||
if (gameScreenSize.Width < 1920 || gameScreenSize.Height < 1080)
|
||||
@@ -219,43 +192,15 @@ public class AutoDomainTask : ISoloTask
|
||||
await Delay(1000, _ct);
|
||||
await Bv.WaitForMainUi(_ct);
|
||||
await Delay(1000, _ct);
|
||||
|
||||
if ("芬德尼尔之顶".Equals(_taskParam.DomainName))
|
||||
var walkKey = User32.VK.VK_W;
|
||||
if (MapLazyAssets.Instance.DomainBackwardList.Contains(_taskParam.DomainName))
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyDown);
|
||||
Thread.Sleep(3000);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyUp);
|
||||
}
|
||||
else if ("无妄引咎密宫".Equals(_taskParam.DomainName))
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Thread.Sleep(500);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Thread.Sleep(100);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveLeft, KeyType.KeyDown);
|
||||
Thread.Sleep(1600);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
}
|
||||
else if ("苍白的遗荣".Equals(_taskParam.DomainName))
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Thread.Sleep(1000);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
}
|
||||
else if ("太山府".Equals(_taskParam.DomainName))
|
||||
{
|
||||
// 直接F即可
|
||||
// nothing to do
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Thread.Sleep(2000);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
walkKey = User32.VK.VK_S;
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop, KeyType.KeyUp); // 可能爬上去了,X键下来
|
||||
await Delay(3000, _ct); // 站稳
|
||||
Simulation.SendInput.Keyboard.KeyDown(walkKey);
|
||||
Thread.Sleep(3500);
|
||||
Simulation.SendInput.Keyboard.KeyUp(walkKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -282,28 +227,20 @@ public class AutoDomainTask : ISoloTask
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task EnterDomain()
|
||||
private void EnterDomain()
|
||||
{
|
||||
var fightAssets = AutoFightAssets.Instance;
|
||||
var fightAssets = AutoFightContext.Instance.FightAssets;
|
||||
|
||||
// 进入秘境
|
||||
for (int i = 0; i < 3; i++) // 3次重试 有时候会拾取晶蝶
|
||||
using var fRectArea = CaptureToRectArea().Find(AutoPickAssets.Instance.FRo);
|
||||
if (!fRectArea.IsEmpty())
|
||||
{
|
||||
using var fRectArea = CaptureToRectArea().Find(AutoPickAssets.Instance.PickRo);
|
||||
if (!fRectArea.IsEmpty())
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(AutoPickAssets.Instance.PickVk);
|
||||
Logger.LogInformation("自动秘境:{Text}", "进入秘境");
|
||||
// 秘境开门动画 5s
|
||||
await Delay(5000, _ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Delay(800, _ct);
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_F);
|
||||
Logger.LogInformation("自动秘境:{Text}", "进入秘境");
|
||||
// 秘境开门动画 5s
|
||||
Sleep(5000, _ct);
|
||||
}
|
||||
|
||||
|
||||
int retryTimes = 0, clickCount = 0;
|
||||
while (retryTimes < 20 && clickCount < 2)
|
||||
{
|
||||
@@ -315,33 +252,33 @@ public class AutoDomainTask : ISoloTask
|
||||
clickCount++;
|
||||
}
|
||||
|
||||
await Delay(1500, _ct);
|
||||
Sleep(1500, _ct);
|
||||
}
|
||||
|
||||
// 载入动画
|
||||
await Delay(3000, _ct);
|
||||
Sleep(3000, _ct);
|
||||
}
|
||||
|
||||
private async Task CloseDomainTip()
|
||||
private void CloseDomainTip()
|
||||
{
|
||||
// 2min的载入时间总够了吧
|
||||
var retryTimes = 0;
|
||||
while (retryTimes < 120)
|
||||
{
|
||||
retryTimes++;
|
||||
using var cactRectArea = CaptureToRectArea().Find(AutoFightAssets.Instance.ClickAnyCloseTipRa);
|
||||
using var cactRectArea = CaptureToRectArea().Find(AutoFightContext.Instance.FightAssets.ClickAnyCloseTipRa);
|
||||
if (!cactRectArea.IsEmpty())
|
||||
{
|
||||
await Delay(1000, _ct);
|
||||
Sleep(1000, _ct);
|
||||
cactRectArea.Click();
|
||||
break;
|
||||
}
|
||||
|
||||
// todo 添加小地图角标位置检测 防止有人手点了
|
||||
await Delay(1000, _ct);
|
||||
Sleep(1000, _ct);
|
||||
}
|
||||
|
||||
await Delay(2000, _ct);
|
||||
Sleep(1500, _ct);
|
||||
}
|
||||
|
||||
private List<CombatCommand> FindCombatScriptAndSwitchAvatar(CombatScenes combatScenes)
|
||||
@@ -365,19 +302,19 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
await Task.Run((Action)(() =>
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Sleep(30, _ct);
|
||||
_simulator.KeyDown(VK.VK_W);
|
||||
Sleep(20);
|
||||
// 组合键好像不能直接用 postmessage
|
||||
if (!_config.WalkToF)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintKeyboard, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(VK.VK_SHIFT);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
using var fRectArea = Common.TaskControl.CaptureToRectArea().Find(AutoPickAssets.Instance.PickRo);
|
||||
using var fRectArea = Common.TaskControl.CaptureToRectArea().Find(AutoPickAssets.Instance.FRo);
|
||||
if (fRectArea.IsEmpty())
|
||||
{
|
||||
Sleep(100, _ct);
|
||||
@@ -385,21 +322,21 @@ public class AutoDomainTask : ISoloTask
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("检测到交互键");
|
||||
Simulation.SendInput.Keyboard.KeyPress(AutoPickAssets.Instance.PickVk);
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
_simulator.KeyUp(VK.VK_W);
|
||||
Sleep(50);
|
||||
if (!_config.WalkToF)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintKeyboard, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(VK.VK_SHIFT);
|
||||
}
|
||||
}
|
||||
}), _ct);
|
||||
}));
|
||||
}
|
||||
|
||||
private Task StartFight(CombatScenes combatScenes, List<CombatCommand> combatCommands)
|
||||
@@ -433,7 +370,6 @@ public class AutoDomainTask : ISoloTask
|
||||
finally
|
||||
{
|
||||
Logger.LogInformation("自动战斗线程结束");
|
||||
combatScenes.AfterTask();
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
@@ -492,7 +428,7 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
using var ra = CaptureToRectArea();
|
||||
|
||||
var endTipsRect = ra.DeriveCrop(AutoFightAssets.Instance.EndTipsUpperRect);
|
||||
var endTipsRect = ra.DeriveCrop(AutoFightContext.Instance.FightAssets.EndTipsUpperRect);
|
||||
var text = OcrFactory.Paddle.Ocr(endTipsRect.SrcGreyMat);
|
||||
if (text.Contains("挑战") || text.Contains("达成"))
|
||||
{
|
||||
@@ -500,7 +436,7 @@ public class AutoDomainTask : ISoloTask
|
||||
return true;
|
||||
}
|
||||
|
||||
endTipsRect = ra.DeriveCrop(AutoFightAssets.Instance.EndTipsRect);
|
||||
endTipsRect = ra.DeriveCrop(AutoFightContext.Instance.FightAssets.EndTipsRect);
|
||||
text = OcrFactory.Paddle.Ocr(endTipsRect.SrcGreyMat);
|
||||
if (text.Contains("自动") || text.Contains("退出"))
|
||||
{
|
||||
@@ -533,7 +469,7 @@ public class AutoDomainTask : ISoloTask
|
||||
if (Bv.CurrentAvatarIsLowHp(CaptureToRectArea()))
|
||||
{
|
||||
// 模拟按键 "Z"
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_Z);
|
||||
Logger.LogInformation("检测到红血,按Z吃药");
|
||||
// TODO 吃饱了会一直吃
|
||||
}
|
||||
@@ -583,16 +519,12 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
return new Task(() =>
|
||||
{
|
||||
var keyConfig = TaskContext.Instance().Config.KeyBindingsConfig;
|
||||
var moveLeftKey = keyConfig.MoveLeft.ToVK();
|
||||
var moveRightKey = keyConfig.MoveRight.ToVK();
|
||||
var moveForwardKey = keyConfig.MoveForward.ToVK();
|
||||
var captureArea = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect;
|
||||
var middleX = captureArea.Width / 2;
|
||||
var leftKeyDown = false;
|
||||
var rightKeyDown = false;
|
||||
var noDetectCount = 0;
|
||||
var prevKey = moveLeftKey;
|
||||
var prevKey = VK.VK_A;
|
||||
var backwardsAndForwardsCount = 0;
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
@@ -608,13 +540,13 @@ public class AutoDomainTask : ISoloTask
|
||||
if (rightKeyDown)
|
||||
{
|
||||
// 先松开D键
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveRightKey);
|
||||
_simulator.KeyUp(VK.VK_D);
|
||||
rightKeyDown = false;
|
||||
}
|
||||
|
||||
if (!leftKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveLeftKey);
|
||||
_simulator.KeyDown(VK.VK_A);
|
||||
leftKeyDown = true;
|
||||
}
|
||||
}
|
||||
@@ -626,13 +558,13 @@ public class AutoDomainTask : ISoloTask
|
||||
if (leftKeyDown)
|
||||
{
|
||||
// 先松开A键
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveLeftKey);
|
||||
_simulator.KeyUp(VK.VK_A);
|
||||
leftKeyDown = false;
|
||||
}
|
||||
|
||||
if (!rightKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveRightKey);
|
||||
_simulator.KeyDown(VK.VK_D);
|
||||
rightKeyDown = true;
|
||||
}
|
||||
}
|
||||
@@ -641,48 +573,42 @@ public class AutoDomainTask : ISoloTask
|
||||
// 树在中间 松开所有键
|
||||
if (rightKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveRightKey);
|
||||
prevKey = moveRightKey;
|
||||
_simulator.KeyUp(VK.VK_D);
|
||||
prevKey = VK.VK_D;
|
||||
rightKeyDown = false;
|
||||
}
|
||||
|
||||
if (leftKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveLeftKey);
|
||||
prevKey = moveLeftKey;
|
||||
_simulator.KeyUp(VK.VK_A);
|
||||
prevKey = VK.VK_A;
|
||||
leftKeyDown = false;
|
||||
}
|
||||
|
||||
// 松开按键后使用小碎步移动
|
||||
if (treeMiddleX < middleX)
|
||||
{
|
||||
if (prevKey == moveRightKey)
|
||||
if (prevKey == VK.VK_D)
|
||||
{
|
||||
backwardsAndForwardsCount++;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveLeftKey);
|
||||
Sleep(60);
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveLeftKey);
|
||||
prevKey = moveLeftKey;
|
||||
_simulator.KeyPress(VK.VK_A, 60);
|
||||
prevKey = VK.VK_A;
|
||||
}
|
||||
else if (treeMiddleX > middleX)
|
||||
{
|
||||
if (prevKey == moveLeftKey)
|
||||
if (prevKey == VK.VK_A)
|
||||
{
|
||||
backwardsAndForwardsCount++;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveRightKey);
|
||||
Sleep(60);
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveRightKey);
|
||||
prevKey = moveRightKey;
|
||||
_simulator.KeyPress(VK.VK_D, 60);
|
||||
prevKey = VK.VK_D;
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveForwardKey);
|
||||
Sleep(60);
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveForwardKey);
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _ct);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
@@ -698,13 +624,13 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
if (leftKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveLeftKey);
|
||||
_simulator.KeyUp(VK.VK_A);
|
||||
leftKeyDown = false;
|
||||
}
|
||||
|
||||
if (!rightKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveRightKey);
|
||||
_simulator.KeyDown(VK.VK_D);
|
||||
rightKeyDown = true;
|
||||
}
|
||||
}
|
||||
@@ -712,13 +638,13 @@ public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
if (rightKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveRightKey);
|
||||
_simulator.KeyUp(VK.VK_D);
|
||||
rightKeyDown = false;
|
||||
}
|
||||
|
||||
if (!leftKeyDown)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveLeftKey);
|
||||
_simulator.KeyDown(VK.VK_A);
|
||||
leftKeyDown = true;
|
||||
}
|
||||
}
|
||||
@@ -727,9 +653,7 @@ public class AutoDomainTask : ISoloTask
|
||||
if (backwardsAndForwardsCount >= _config.LeftRightMoveTimes)
|
||||
{
|
||||
// 左右移动5次说明已经在树中心了
|
||||
Simulation.SendInput.Keyboard.KeyDown(moveForwardKey);
|
||||
Sleep(60);
|
||||
Simulation.SendInput.Keyboard.KeyUp(moveForwardKey);
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _ct);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
@@ -848,7 +772,7 @@ public class AutoDomainTask : ISoloTask
|
||||
break;
|
||||
}
|
||||
|
||||
var useCondensedResinRa = CaptureToRectArea().Find(AutoFightAssets.Instance.UseCondensedResinRa);
|
||||
var useCondensedResinRa = CaptureToRectArea().Find(AutoFightContext.Instance.FightAssets.UseCondensedResinRa);
|
||||
if (!useCondensedResinRa.IsEmpty())
|
||||
{
|
||||
useCondensedResinRa.Click();
|
||||
@@ -888,13 +812,13 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
|
||||
// 优先点击继续
|
||||
using var confirmRectArea = ra.Find(AutoFightAssets.Instance.ConfirmRa);
|
||||
using var confirmRectArea = ra.Find(AutoFightContext.Instance.FightAssets.ConfirmRa);
|
||||
if (!confirmRectArea.IsEmpty())
|
||||
{
|
||||
if (isLastTurn)
|
||||
{
|
||||
// 最后一回合 退出
|
||||
var exitRectArea = ra.Find(AutoFightAssets.Instance.ExitRa);
|
||||
var exitRectArea = ra.Find(AutoFightContext.Instance.FightAssets.ExitRa);
|
||||
if (!exitRectArea.IsEmpty())
|
||||
{
|
||||
exitRectArea.Click();
|
||||
@@ -912,7 +836,7 @@ public class AutoDomainTask : ISoloTask
|
||||
if (condensedResinCount == 0 && fragileResinCount < 20)
|
||||
{
|
||||
// 没有体力了退出
|
||||
var exitRectArea = ra.Find(AutoFightAssets.Instance.ExitRa);
|
||||
var exitRectArea = ra.Find(AutoFightContext.Instance.FightAssets.ExitRa);
|
||||
if (!exitRectArea.IsEmpty())
|
||||
{
|
||||
exitRectArea.Click();
|
||||
@@ -943,7 +867,7 @@ public class AutoDomainTask : ISoloTask
|
||||
|
||||
var ra = CaptureToRectArea();
|
||||
// 浓缩树脂
|
||||
var condensedResinCountRa = ra.Find(AutoFightAssets.Instance.CondensedResinCountRa);
|
||||
var condensedResinCountRa = ra.Find(AutoFightContext.Instance.FightAssets.CondensedResinCountRa);
|
||||
if (!condensedResinCountRa.IsEmpty())
|
||||
{
|
||||
// 图像右侧就是浓缩树脂数量
|
||||
@@ -954,7 +878,7 @@ public class AutoDomainTask : ISoloTask
|
||||
}
|
||||
|
||||
// 脆弱树脂
|
||||
var fragileResinCountRa = ra.Find(AutoFightAssets.Instance.FragileResinCountRa);
|
||||
var fragileResinCountRa = ra.Find(AutoFightContext.Instance.FightAssets.FragileResinCountRa);
|
||||
if (!fragileResinCountRa.IsEmpty())
|
||||
{
|
||||
// 图像右侧就是脆弱树脂数量
|
||||
|
||||
@@ -12,7 +12,6 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
public List<Rect> AvatarSideIconRectList; // 侧边栏角色头像 非联机状态下
|
||||
public List<Rect> AvatarIndexRectList; // 侧边栏角色头像对应的白色块 非联机状态下
|
||||
public Rect ERect;
|
||||
public Rect ECooldownRect;
|
||||
public Rect QRect;
|
||||
public Rect EndTipsUpperRect; // 挑战达成提示
|
||||
public Rect EndTipsRect;
|
||||
@@ -48,8 +47,6 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
(int)(355 * AssetScale), (int)(465 * AssetScale));
|
||||
ERect = new Rect(CaptureRect.Width - (int)(267 * AssetScale), CaptureRect.Height - (int)(132 * AssetScale),
|
||||
(int)(77 * AssetScale), (int)(77 * AssetScale));
|
||||
ECooldownRect = new Rect(CaptureRect.Width - (int)(241 * AssetScale), CaptureRect.Height - (int)(97 * AssetScale),
|
||||
(int)(41 * AssetScale), (int)(18 * AssetScale));
|
||||
QRect = new Rect(CaptureRect.Width - (int)(157 * AssetScale), CaptureRect.Height - (int)(165 * AssetScale),
|
||||
(int)(110 * AssetScale), (int)(110 * AssetScale));
|
||||
// 小道具位置 1920-133,800,60,50
|
||||
|
||||
@@ -1620,8 +1620,7 @@
|
||||
"卡齐纳",
|
||||
"卡齐那",
|
||||
"卡其那",
|
||||
"冲天钻钻",
|
||||
"岩莉莉"
|
||||
"冲天钻钻"
|
||||
],
|
||||
"burstCD": 18,
|
||||
"id": "10000100",
|
||||
@@ -1635,8 +1634,7 @@
|
||||
"基尼奇",
|
||||
"Kinich",
|
||||
"基哥",
|
||||
"基尼齐",
|
||||
"蜘蛛侠"
|
||||
"基尼齐"
|
||||
],
|
||||
"burstCD": 18,
|
||||
"id": "10000101",
|
||||
@@ -1686,8 +1684,7 @@
|
||||
"恰斯卡",
|
||||
"Chasca",
|
||||
"武卡",
|
||||
"调停人",
|
||||
"鸟人"
|
||||
"调停人"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000104",
|
||||
@@ -1699,10 +1696,9 @@
|
||||
{
|
||||
"alias": [
|
||||
"欧洛伦",
|
||||
"Ororon",
|
||||
"Olorun",
|
||||
"庇笛",
|
||||
"孙子",
|
||||
"大孙子",
|
||||
"蝙蝠侠"
|
||||
],
|
||||
"burstCD": 15,
|
||||
@@ -1711,55 +1707,5 @@
|
||||
"nameEn": "Olorun",
|
||||
"skillCD": 15,
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"玛薇卡",
|
||||
"Mavuika",
|
||||
"火神",
|
||||
"马薇卡",
|
||||
"玛维卡",
|
||||
"马维卡"
|
||||
],
|
||||
"burstCD": 18,
|
||||
"id": "10000106",
|
||||
"name": "玛薇卡",
|
||||
"nameEn": "Mavuika",
|
||||
"skillCD": 15,
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"茜特菈莉",
|
||||
"Citlali",
|
||||
"西特菈莉",
|
||||
"西特拉莉",
|
||||
"茜特拉莉",
|
||||
"西特拉利",
|
||||
"黑曜石奶奶",
|
||||
"黑曜石",
|
||||
"奶奶",
|
||||
"老伴"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000107",
|
||||
"name": "茜特菈莉",
|
||||
"nameEn": "Citlali",
|
||||
"skillCD": 16,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [
|
||||
"蓝砚",
|
||||
"蓝燕",
|
||||
"兰砚",
|
||||
"兰燕"
|
||||
],
|
||||
"burstCD": 15,
|
||||
"id": "10000108",
|
||||
"name": "蓝砚",
|
||||
"nameEn": "Lanyan",
|
||||
"skillCD": 16,
|
||||
"weapon": "10"
|
||||
}
|
||||
]
|
||||
@@ -3,10 +3,6 @@ using System;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动战斗配置
|
||||
/// </summary>
|
||||
@@ -25,105 +21,10 @@ public partial class AutoFightConfig : ObservableObject
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _fightFinishDetectEnabled = true;
|
||||
/// <summary>
|
||||
/// 根据技能CD优化出招人员
|
||||
/// 根据填入人或人和cd,来决定当此人元素战技cd未结束时,跳过此人出招,来优化战斗流程,可填入人名或人名数字(用逗号分隔),
|
||||
/// 多种用分号分隔,例如:白术;钟离,12;,如果人名,则用内置cd检查,如果是人名和数字,则把数字当做出招cd(秒)。
|
||||
/// </summary>
|
||||
[ObservableProperty] private string _actionSchedulerByCd = "";
|
||||
|
||||
[Serializable]
|
||||
public partial class FightFinishDetectConfig : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断战斗结束读条颜色,不同帧率可能下会有些不同,默认为95,235,255
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _battleEndProgressBarColor = "";
|
||||
|
||||
/// <summary>
|
||||
/// 对于上方颜色地偏差值,即±某个值,例如 6或6,6,6,前者表示所有偏差值都一样,后者则可以分别设置
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _battleEndProgressBarColorTolerance = "";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 快速检查战斗结束,在一轮脚本中,可以每隔一定秒数(默认为5)或指定角色操作后,去检查(在每个角色完成该轮脚本时)。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _fastCheckEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// 快速检查战斗结束的参数,可填入数字和人名,多种用分号分隔,例如:15,白术;钟离;,如果是数字(小于等于0则不会根据时间去检查),则指定检查间隔,如果是人名,则该角色执行一轮操作后进行检查。同时每轮结束后检查不变。
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _fastCheckParams = "";
|
||||
|
||||
/// <summary>
|
||||
/// 检查战斗结束的延时,即角色,默认为1.5秒。也可以指定特定角色之后延时多少时间检查。格式如:2.5;白术,1.5;钟离,1.0;
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _checkEndDelay = "";
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 战斗结束相关配置
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private FightFinishDetectConfig _finishDetectConfig = new();
|
||||
|
||||
/// <summary>
|
||||
/// 检测战斗结束,默认为每轮脚本后检查
|
||||
/// 检测战斗结束
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _pickDropsAfterFightEnabled = true;
|
||||
|
||||
[Serializable]
|
||||
public partial class PickDropsAfterFightConfig : ObservableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 前进次数
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _forwardTimes = 6;
|
||||
|
||||
/// <summary>
|
||||
/// 校准次数
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _calibrationTimes = 15;
|
||||
|
||||
/// <summary>
|
||||
/// 衰减因子
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private double _decayFactor = 0.7;
|
||||
|
||||
/// <summary>
|
||||
/// 前进量(秒),设置为0时在[1,3]中随机
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _forwardSeconds = 2;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 掉落寻物相关配置
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private PickDropsAfterFightConfig _pickDropsConfig = new();
|
||||
|
||||
/// <summary>
|
||||
/// 战斗结束后,如果存在枫原万叶,则使用该角色捡材料
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _kazuhaPickupEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗超时,单位秒
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private int _timeout = 120;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
// using BetterGenshinImpact.Core.Simulator;
|
||||
// using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
// using BetterGenshinImpact.Model;
|
||||
//
|
||||
// namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using BetterGenshinImpact.Model;
|
||||
|
||||
// /// <summary>
|
||||
// /// 自动战斗上下文
|
||||
// /// 请在启动BetterGI以后再初始化
|
||||
// /// </summary>
|
||||
// public class AutoFightContext : Singleton<AutoFightContext>
|
||||
// {
|
||||
// private AutoFightContext()
|
||||
// {
|
||||
// Simulator = TaskContext.Instance().PostMessageSimulator;
|
||||
// }
|
||||
//
|
||||
// /// <summary>
|
||||
// /// find资源
|
||||
// /// </summary>
|
||||
// public AutoFightAssets FightAssets => AutoFightAssets.Instance;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 战斗专用的PostMessage模拟键鼠操作
|
||||
// /// </summary>
|
||||
// public readonly PostMessageSimulator Simulator;
|
||||
// }
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
/// <summary>
|
||||
/// 自动战斗上下文
|
||||
/// 请在启动BetterGI以后再初始化
|
||||
/// </summary>
|
||||
public class AutoFightContext : Singleton<AutoFightContext>
|
||||
{
|
||||
private AutoFightContext()
|
||||
{
|
||||
Simulator = Simulation.PostMessage(TaskContext.Instance().GameHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// find资源
|
||||
/// </summary>
|
||||
public AutoFightAssets FightAssets => AutoFightAssets.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// 战斗专用的PostMessage模拟键鼠操作
|
||||
/// </summary>
|
||||
public readonly PostMessageSimulator Simulator;
|
||||
}
|
||||
@@ -2,53 +2,11 @@
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class AutoFightParam : BaseTaskParam
|
||||
public class AutoFightParam(string path) : BaseTaskParam
|
||||
{
|
||||
public class FightFinishDetectConfig
|
||||
{
|
||||
public string BattleEndProgressBarColor { get; set; }= "";
|
||||
|
||||
public string BattleEndProgressBarColorTolerance { get; set; }= "";
|
||||
public bool FastCheckEnabled = false;
|
||||
public string FastCheckParams = "";
|
||||
public string CheckEndDelay = "";
|
||||
}
|
||||
|
||||
public AutoFightParam(string path, AutoFightConfig autoFightConfig)
|
||||
{
|
||||
CombatStrategyPath = path;
|
||||
Timeout = autoFightConfig.Timeout;
|
||||
FightFinishDetectEnabled = autoFightConfig.FightFinishDetectEnabled;
|
||||
PickDropsAfterFightEnabled = autoFightConfig.PickDropsAfterFightEnabled;
|
||||
KazuhaPickupEnabled = autoFightConfig.KazuhaPickupEnabled;
|
||||
ActionSchedulerByCd = autoFightConfig.ActionSchedulerByCd;
|
||||
|
||||
FinishDetectConfig.FastCheckEnabled = autoFightConfig.FinishDetectConfig.FastCheckEnabled;
|
||||
FinishDetectConfig.FastCheckParams = autoFightConfig.FinishDetectConfig.FastCheckParams;
|
||||
FinishDetectConfig.CheckEndDelay = autoFightConfig.FinishDetectConfig.CheckEndDelay;
|
||||
|
||||
//下面参数固定,只取自动战斗里面的
|
||||
FinishDetectConfig.BattleEndProgressBarColor = TaskContext.Instance().Config.AutoFightConfig.FinishDetectConfig.BattleEndProgressBarColor;
|
||||
FinishDetectConfig.BattleEndProgressBarColorTolerance = TaskContext.Instance().Config.AutoFightConfig.FinishDetectConfig.BattleEndProgressBarColorTolerance;
|
||||
}
|
||||
|
||||
public FightFinishDetectConfig FinishDetectConfig { get; set; } = new();
|
||||
|
||||
public string CombatStrategyPath { get; set; }
|
||||
public string CombatStrategyPath { get; set; } = path;
|
||||
|
||||
public bool FightFinishDetectEnabled { get; set; } = false;
|
||||
|
||||
public bool PickDropsAfterFightEnabled { get; set; } = false;
|
||||
|
||||
public int Timeout { get; set; } = 120;
|
||||
|
||||
public bool KazuhaPickupEnabled = true;
|
||||
public string ActionSchedulerByCd = "";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,19 @@
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using OpenCvSharp;
|
||||
using Vanara;
|
||||
using Vanara.PInvoke;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
@@ -41,137 +33,6 @@ public class AutoFightTask : ISoloTask
|
||||
|
||||
private readonly double _dpi = TaskContext.Instance().DpiScale;
|
||||
|
||||
|
||||
private class TaskFightFinishDetectConfig
|
||||
{
|
||||
public int DelayTime = 1500;
|
||||
public Dictionary<string, int> DelayTimes = new();
|
||||
public double CheckTime = 5;
|
||||
public List<string> CheckNames = new();
|
||||
public bool FastCheckEnabled;
|
||||
|
||||
public TaskFightFinishDetectConfig(AutoFightParam.FightFinishDetectConfig finishDetectConfig)
|
||||
{
|
||||
FastCheckEnabled = finishDetectConfig.FastCheckEnabled;
|
||||
ParseCheckTimeString(finishDetectConfig.FastCheckParams, out CheckTime, CheckNames);
|
||||
ParseFastCheckEndDelayString(finishDetectConfig.CheckEndDelay, out DelayTime, DelayTimes);
|
||||
BattleEndProgressBarColor = ParseStringToTuple(finishDetectConfig.BattleEndProgressBarColor, (95, 235, 255));
|
||||
BattleEndProgressBarColorTolerance = ParseSingleOrCommaSeparated(finishDetectConfig.BattleEndProgressBarColorTolerance, (6, 6, 6));
|
||||
}
|
||||
|
||||
public (int, int, int) BattleEndProgressBarColor { get; }
|
||||
public (int, int, int) BattleEndProgressBarColorTolerance { get; }
|
||||
|
||||
public static void ParseCheckTimeString(
|
||||
string input,
|
||||
out double checkTime,
|
||||
List<string> names)
|
||||
{
|
||||
checkTime = 5;
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return; // 直接返回
|
||||
}
|
||||
|
||||
var uniqueNames = new HashSet<string>(); // 用于临时去重的集合
|
||||
|
||||
// 按分号分割字符串
|
||||
var segments = input.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
var trimmedSegment = segment.Trim();
|
||||
|
||||
// 如果是纯数字部分
|
||||
if (double.TryParse(trimmedSegment, NumberStyles.Float, CultureInfo.InvariantCulture, out double number))
|
||||
{
|
||||
checkTime = number; // 更新 CheckTime
|
||||
}
|
||||
else if (!uniqueNames.Contains(trimmedSegment)) // 如果是非数字且不重复
|
||||
{
|
||||
uniqueNames.Add(trimmedSegment); // 添加到集合
|
||||
}
|
||||
}
|
||||
|
||||
names.AddRange(uniqueNames); // 将集合转换为列表
|
||||
}
|
||||
|
||||
public static void ParseFastCheckEndDelayString(
|
||||
string input,
|
||||
out int delayTime,
|
||||
Dictionary<string, int> nameDelayMap)
|
||||
{
|
||||
delayTime = 1500;
|
||||
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return; // 直接返回
|
||||
}
|
||||
|
||||
// 分割字符串,以分号为分隔符
|
||||
var segments = input.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
var parts = segment.Split(',');
|
||||
|
||||
// 如果是纯数字部分
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
if (double.TryParse(parts[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out double number))
|
||||
{
|
||||
delayTime = (int)(number * 1000); // 更新 delayTime
|
||||
}
|
||||
}
|
||||
// 如果是名字,数字格式
|
||||
else if (parts.Length == 2)
|
||||
{
|
||||
string name = parts[0].Trim();
|
||||
if (double.TryParse(parts[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out double value))
|
||||
{
|
||||
nameDelayMap[name] = (int)(value * 1000); // 更新字典,取最后一个值
|
||||
}
|
||||
}
|
||||
// 其他格式,跳过不处理
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool IsSingleNumber(string input, out int result)
|
||||
{
|
||||
return int.TryParse(input, out result);
|
||||
}
|
||||
|
||||
static (int, int, int) ParseSingleOrCommaSeparated(string input, (int, int, int) defaultValue)
|
||||
{
|
||||
// 如果是单个数字
|
||||
if (IsSingleNumber(input, out var singleNumber))
|
||||
{
|
||||
return (singleNumber, singleNumber, singleNumber);
|
||||
}
|
||||
|
||||
return ParseStringToTuple(input, defaultValue);
|
||||
}
|
||||
|
||||
static (int, int, int) ParseStringToTuple(string input, (int, int, int) defaultValue)
|
||||
{
|
||||
// 尝试按逗号分割字符串
|
||||
var parts = input.Split(',');
|
||||
if (parts.Length == 3 &&
|
||||
int.TryParse(parts[0], out var num1) &&
|
||||
int.TryParse(parts[1], out var num2) &&
|
||||
int.TryParse(parts[2], out var num3))
|
||||
{
|
||||
return (num1, num2, num3);
|
||||
}
|
||||
|
||||
// 如果解析失败,返回默认值
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private TaskFightFinishDetectConfig _finishDetectConfig;
|
||||
|
||||
public AutoFightTask(AutoFightParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
@@ -179,18 +40,10 @@ public class AutoFightTask : ISoloTask
|
||||
|
||||
if (_taskParam.FightFinishDetectEnabled)
|
||||
{
|
||||
_predictor = BgiYoloV8PredictorFactory.GetPredictor(@"Assets\Model\World\bgi_world.onnx");
|
||||
_predictor = new BgiYoloV8Predictor(@"Assets\Model\World\bgi_world.onnx");
|
||||
}
|
||||
|
||||
_finishDetectConfig = new TaskFightFinishDetectConfig(_taskParam.FinishDetectConfig);
|
||||
}
|
||||
|
||||
// 方法1:判断是否是单个数字
|
||||
|
||||
/*public int delayTime=1500;
|
||||
public Dictionary<string, int> delayTimes = new();
|
||||
public double checkTime = 5;
|
||||
public List<string> checkNames = new();*/
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
_ct = ct;
|
||||
@@ -202,7 +55,6 @@ public class AutoFightTask : ISoloTask
|
||||
throw new Exception("识别队伍角色失败");
|
||||
}
|
||||
|
||||
var actionSchedulerByCd = ParseStringToDictionary(_taskParam.ActionSchedulerByCd);
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
|
||||
|
||||
// 新的取消token
|
||||
@@ -210,22 +62,7 @@ public class AutoFightTask : ISoloTask
|
||||
ct.Register(cts2.Cancel);
|
||||
|
||||
combatScenes.BeforeTask(cts2.Token);
|
||||
TimeSpan fightTimeout = TimeSpan.FromSeconds(_taskParam.Timeout); // 战斗超时时间
|
||||
Stopwatch timeoutStopwatch = Stopwatch.StartNew();
|
||||
|
||||
Stopwatch checkFightFinishStopwatch = Stopwatch.StartNew();
|
||||
TimeSpan checkFightFinishTime = TimeSpan.FromSeconds(_finishDetectConfig.CheckTime); //检查战斗超时时间的超时时间
|
||||
|
||||
|
||||
//战斗前检查,可做成配置
|
||||
/* if (await CheckFightFinish()) {
|
||||
return;
|
||||
}*/
|
||||
var fightEndFlag = false;
|
||||
string lastFightName = "";
|
||||
string skipFightName = "";
|
||||
//统计切换人打架次数
|
||||
var countFight = 0;
|
||||
// 战斗操作
|
||||
var fightTask = Task.Run(async () =>
|
||||
{
|
||||
@@ -234,90 +71,12 @@ public class AutoFightTask : ISoloTask
|
||||
while (!cts2.Token.IsCancellationRequested)
|
||||
{
|
||||
// 通用化战斗策略
|
||||
for (var i = 0; i < combatCommands.Count; i++)
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
var command = combatCommands[i];
|
||||
if (timeoutStopwatch.Elapsed > fightTimeout)
|
||||
{
|
||||
Logger.LogInformation("战斗超时结束");
|
||||
fightEndFlag = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//根据元素技能冷却事件优化出招流程,只有当人物切换后才会触发检查
|
||||
double skillCd;
|
||||
if (lastFightName != command.Name && actionSchedulerByCd.TryGetValue(command.Name,out skillCd))
|
||||
{
|
||||
var avatar = combatScenes.SelectAvatar(command.Name);
|
||||
if (avatar == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (skillCd < 0)
|
||||
{
|
||||
skillCd = FindMax([avatar.SkillCd,avatar.SkillHoldCd]);
|
||||
}
|
||||
var dif=(DateTime.UtcNow - avatar.LastSkillTime);
|
||||
//当技能未冷却时,跳过此次出招
|
||||
if ((DateTime.UtcNow -avatar.LastSkillTime).TotalSeconds < skillCd)
|
||||
{
|
||||
if (skipFightName != command.Name)
|
||||
{
|
||||
Logger.LogInformation($"{command.Name}cd冷却为{skillCd}秒,剩余{skillCd-dif.TotalSeconds}秒,跳过此次行动");
|
||||
}
|
||||
skipFightName = command.Name;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
command.Execute(combatScenes);
|
||||
//统计战斗人次
|
||||
if (i == combatCommands.Count - 1 || command.Name != combatCommands[i + 1].Name)
|
||||
{
|
||||
countFight++;
|
||||
}
|
||||
|
||||
lastFightName = command.Name;
|
||||
if (!fightEndFlag && _taskParam is { FightFinishDetectEnabled: true })
|
||||
{
|
||||
//处于最后一个位置,或者当前执行人和下一个人名字不一样的情况,满足一定条件(开启快速检查,并且检查时间大于0或人名存在配置)检查战斗
|
||||
if (i == combatCommands.Count - 1
|
||||
|| (
|
||||
_finishDetectConfig.FastCheckEnabled && command.Name != combatCommands[i + 1].Name &&
|
||||
((_finishDetectConfig.CheckTime > 0 && checkFightFinishStopwatch.Elapsed > checkFightFinishTime)
|
||||
|| _finishDetectConfig.CheckNames.Contains(command.Name))
|
||||
))
|
||||
{
|
||||
checkFightFinishStopwatch.Restart();
|
||||
var delayTime = _finishDetectConfig.DelayTime;
|
||||
if (_finishDetectConfig.DelayTimes.TryGetValue(command.Name, out var time))
|
||||
{
|
||||
delayTime = time;
|
||||
Logger.LogInformation($"{command.Name}结束后,延时检查为{delayTime}毫秒");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation($"延时检查为{delayTime}毫秒");
|
||||
}
|
||||
|
||||
/*if (i<combatCommands.Count - 1)
|
||||
{
|
||||
Logger.LogInformation($"{command.Name}下一个人为{combatCommands[i+1].Name}毫秒");
|
||||
}*/
|
||||
fightEndFlag = await CheckFightFinish(delayTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (fightEndFlag)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (fightEndFlag)
|
||||
if (await CheckFightFinish())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -327,7 +86,6 @@ public class AutoFightTask : ISoloTask
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
Debug.WriteLine(e.StackTrace);
|
||||
throw;
|
||||
}
|
||||
}, cts2.Token);
|
||||
|
||||
@@ -363,187 +121,54 @@ public class AutoFightTask : ISoloTask
|
||||
// }, cts2.Token);
|
||||
//
|
||||
// await Task.WhenAll(fightTask, endTask);
|
||||
if (_taskParam.KazuhaPickupEnabled)
|
||||
{
|
||||
// 队伍中存在万叶的时候使用一次长E
|
||||
var kazuha = combatScenes.Avatars.FirstOrDefault(a => a.Name == "枫原万叶");
|
||||
if (kazuha != null)
|
||||
{
|
||||
var time = DateTime.UtcNow - kazuha.LastSkillTime;
|
||||
//当万叶cd大于3时或战斗人次少于2时(通常无怪物情况下),此时不再触发万叶拾取,
|
||||
if (!(countFight < 2 || lastFightName == "枫原万叶" && time.TotalSeconds > 3))
|
||||
{
|
||||
Logger.LogInformation("使用枫原万叶长E拾取掉落物");
|
||||
await Delay(300, ct);
|
||||
if (kazuha.TrySwitch())
|
||||
{
|
||||
time = DateTime.UtcNow - kazuha.LastSkillTime;
|
||||
if (time.TotalMilliseconds > 0 && time.TotalSeconds <= kazuha.SkillHoldCd)
|
||||
{
|
||||
Logger.LogInformation("枫原万叶长E技能可能处于冷却中,等待 {Time} s", time.TotalSeconds);
|
||||
await Delay((int)Math.Ceiling(time.TotalMilliseconds), ct);
|
||||
}
|
||||
|
||||
kazuha.UseSkill(true);
|
||||
await Task.Delay(100);
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
await Delay(1500, ct);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation((countFight < 2 ? "首个人出招就结束战斗,应该无怪物" : "距最近一次万叶出招,时间过短") + ",跳过此次万叶拾取!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_taskParam is { PickDropsAfterFightEnabled: true })
|
||||
if (_taskParam is { FightFinishDetectEnabled: true, PickDropsAfterFightEnabled: true })
|
||||
{
|
||||
// 执行自动拾取掉落物的功能
|
||||
await new ScanPickTask().Start(ct);
|
||||
}
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
{
|
||||
AssertUtils.CheckGameResolution("自动战斗");
|
||||
var gameScreenSize = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
|
||||
if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
|
||||
{
|
||||
Logger.LogWarning("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏可能无法正常使用自动战斗功能 !", gameScreenSize.Width, gameScreenSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
static bool AreDifferencesWithinBounds((int, int, int) a, (int, int, int) b, (int, int, int) c)
|
||||
{
|
||||
// 计算每个位置的差值绝对值并进行比较
|
||||
return Math.Abs(a.Item1 - b.Item1) < c.Item1 &&
|
||||
Math.Abs(a.Item2 - b.Item2) < c.Item2 &&
|
||||
Math.Abs(a.Item3 - b.Item3) < c.Item3;
|
||||
}
|
||||
|
||||
private async Task<bool> CheckFightFinish(int delayTime = 1500)
|
||||
private async Task<bool> CheckFightFinish()
|
||||
{
|
||||
// YOLO 判断血条和怪物位置
|
||||
// if (HasFightFlagByYolo(CaptureToRectArea()))
|
||||
// {
|
||||
// _lastFightFlagTime = DateTime.Now;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
|
||||
//Random random = new Random();
|
||||
//double randomFraction = random.NextDouble(); // 生成 0 到 1 之间的随机小数
|
||||
//此处随机数,防止固定招式下,使按L正好处于招式下,导致无法准确判断战斗结束
|
||||
// double randomNumber = 1 + (randomFraction * (3 - 1));
|
||||
if (HasFightFlagByYolo(CaptureToRectArea()))
|
||||
{
|
||||
_lastFightFlagTime = DateTime.Now;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 几秒内没有检测到血条和怪物位置,则开始旋转视角重新检测
|
||||
//if ((DateTime.Now - _lastFightFlagTime).TotalSeconds > randomNumber)
|
||||
//{
|
||||
// 旋转完毕后都没有检测到血条和怪物位置,则按L键确认战斗结束
|
||||
/**
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
await Delay(300, _ct);
|
||||
for (var i = 0; i < 8; i++)
|
||||
if ((DateTime.Now - _lastFightFlagTime).TotalSeconds > 3)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)(500 * _dpi), 0);
|
||||
await Delay(800, _ct); // 等待视角稳定
|
||||
if (HasFightFlagByYolo(CaptureToRectArea()))
|
||||
// 旋转完毕后都没有检测到血条和怪物位置,则按L键确认战斗结束
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
await Delay(300, _ct);
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
_lastFightFlagTime = DateTime.Now;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
await Delay(delayTime, _ct);
|
||||
Logger.LogInformation("打开编队界面检查战斗是否结束");
|
||||
// 最终方案确认战斗结束
|
||||
Simulation.SendInput.SimulateAction(GIActions.OpenPartySetupScreen);
|
||||
await Delay(450, _ct);
|
||||
var ra = CaptureToRectArea();
|
||||
var b3 = ra.SrcMat.At<Vec3b>(50, 790); //进度条颜色
|
||||
var whiteTile = ra.SrcMat.At<Vec3b>(50, 768); //白块
|
||||
if (IsWhite(whiteTile.Item2, whiteTile.Item1, whiteTile.Item0) && IsYellow(b3.Item2, b3.Item1, b3.Item0) /* AreDifferencesWithinBounds(_finishDetectConfig.BattleEndProgressBarColor, (b3.Item0, b3.Item1, b3.Item2), _finishDetectConfig.BattleEndProgressBarColorTolerance)*/)
|
||||
{
|
||||
Logger.LogInformation("识别到战斗结束");
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
return true;
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
Logger.LogInformation($"未识别到战斗结束yellow{b3.Item0},{b3.Item1},{b3.Item2}");
|
||||
Logger.LogInformation($"未识别到战斗结束white{whiteTile.Item0},{whiteTile.Item1},{whiteTile.Item2}");
|
||||
/**
|
||||
if (!Bv.IsInMainUi(ra))
|
||||
{
|
||||
// 如果不在主界面,说明异常,直接结束战斗继续下一步(路径追踪下一步会进入异常处理)
|
||||
Logger.LogInformation("当前不在主界面,直接结束战斗!");
|
||||
return true;
|
||||
}**/
|
||||
|
||||
_lastFightFlagTime = DateTime.Now;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsYellow(int r, int g, int b)
|
||||
{
|
||||
//Logger.LogInformation($"IsYellow({r},{g},{b})");
|
||||
// 黄色范围:R高,G高,B低
|
||||
return (r >= 200 && r <= 255) &&
|
||||
(g >= 200 && g <= 255) &&
|
||||
(b >= 0 && b <= 100);
|
||||
}
|
||||
|
||||
bool IsWhite(int r, int g, int b)
|
||||
{
|
||||
//Logger.LogInformation($"IsWhite({r},{g},{b})");
|
||||
// 白色范围:R高,G高,B低
|
||||
return (r >= 240 && r <= 255) &&
|
||||
(g >= 240 && g <= 255) &&
|
||||
(b >= 240 && b <= 255);
|
||||
}
|
||||
static double FindMax(double[] numbers)
|
||||
{
|
||||
if (numbers == null || numbers.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("The array is empty or null.");
|
||||
}
|
||||
|
||||
double max = numbers[0]>10000 ? 0 : numbers[0];
|
||||
foreach (var num in numbers)
|
||||
{
|
||||
var cpnum = numbers[0]>10000 ? 0 : num;
|
||||
max = Math.Max(max, num);
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
private static Dictionary<string, double> ParseStringToDictionary(string input,double defaultValue=-1)
|
||||
{
|
||||
var dictionary = new Dictionary<string, double>();
|
||||
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return dictionary; // 返回空字典
|
||||
}
|
||||
|
||||
string[] pairs = input.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
foreach (var pair in pairs)
|
||||
{
|
||||
var parts = pair.Split(',', StringSplitOptions.TrimEntries);
|
||||
|
||||
if (parts.Length > 0)
|
||||
{
|
||||
string name = parts[0];
|
||||
double value = defaultValue;
|
||||
|
||||
if (parts.Length > 1 && double.TryParse(parts[1], out var parsedValue))
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)(500 * _dpi), 0);
|
||||
await Delay(800, _ct); // 等待视角稳定
|
||||
if (HasFightFlagByYolo(CaptureToRectArea()))
|
||||
{
|
||||
value = parsedValue;
|
||||
_lastFightFlagTime = DateTime.Now;
|
||||
return false;
|
||||
}
|
||||
|
||||
dictionary[name] = value;
|
||||
}
|
||||
|
||||
// 最终方案确认战斗结束
|
||||
Logger.LogInformation("识别到战斗结束");
|
||||
return true;
|
||||
}
|
||||
|
||||
return dictionary;
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool HasFightFlagByYolo(ImageRegion imageRegion)
|
||||
@@ -566,4 +191,4 @@ public class AutoFightTask : ISoloTask
|
||||
// // 要大于 gadgetMat 的 1/2
|
||||
// return list.Any(r => r.Width > gadgetMat.Width / 2 && r.Height > gadgetMat.Height / 2);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Config;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
@@ -12,13 +11,10 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
|
||||
@@ -57,11 +53,6 @@ public class Avatar
|
||||
/// </summary>
|
||||
public double SkillHoldCd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近一次使用元素战技的时间
|
||||
/// </summary>
|
||||
public DateTime LastSkillTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 元素爆发CD
|
||||
/// </summary>
|
||||
@@ -92,7 +83,6 @@ public class Avatar
|
||||
/// </summary>
|
||||
public CombatScenes CombatScenes { get; set; }
|
||||
|
||||
|
||||
public Avatar(CombatScenes combatScenes, string name, int index, Rect nameRect)
|
||||
{
|
||||
CombatScenes = combatScenes;
|
||||
@@ -120,14 +110,14 @@ public class Avatar
|
||||
{
|
||||
Logger.LogWarning("检测到复苏界面,存在角色被击败,前往七天神像复活");
|
||||
// 先打开地图
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE); // NOTE: 此处按下Esc是为了关闭复苏界面,无需改键
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);
|
||||
Sleep(600, Ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.OpenMap);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_M);
|
||||
// tp 到七天神像复活
|
||||
var tpTask = new TpTask(Ct);
|
||||
tpTask.TpToStatueOfTheSeven().Wait(Ct);
|
||||
tpTask.Tp(TpTask.ReviveStatueOfTheSevenPointX, TpTask.ReviveStatueOfTheSevenPointY, true).Wait(Ct);
|
||||
|
||||
throw new RetryException("检测到复苏界面,存在角色被击败,前往七天神像复活");
|
||||
throw new Exception("检测到复苏界面,存在角色被击败,前往七天神像复活");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,27 +143,7 @@ public class Avatar
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Index)
|
||||
{
|
||||
case 1:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember1);
|
||||
break;
|
||||
case 2:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember2);
|
||||
break;
|
||||
case 3:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember3);
|
||||
break;
|
||||
case 4:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember4);
|
||||
break;
|
||||
case 5:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_1 + (byte)Index - 1);
|
||||
// Debug.WriteLine($"切换到{Index}号位");
|
||||
// Cv2.ImWrite($"log/切换.png", region.SrcMat);
|
||||
Sleep(250, Ct);
|
||||
@@ -209,26 +179,7 @@ public class Avatar
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (Index)
|
||||
{
|
||||
case 1:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember1);
|
||||
break;
|
||||
case 2:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember2);
|
||||
break;
|
||||
case 3:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember3);
|
||||
break;
|
||||
case 4:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember4);
|
||||
break;
|
||||
case 5:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_1 + (byte)Index - 1);
|
||||
|
||||
Sleep(250, Ct);
|
||||
}
|
||||
@@ -253,27 +204,7 @@ public class Avatar
|
||||
return;
|
||||
}
|
||||
|
||||
switch (Index)
|
||||
{
|
||||
case 1:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember1);
|
||||
break;
|
||||
case 2:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember2);
|
||||
break;
|
||||
case 3:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember3);
|
||||
break;
|
||||
case 4:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember4);
|
||||
break;
|
||||
case 5:
|
||||
Simulation.SendInput.SimulateAction(GIActions.SwitchMember5);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_1 + (byte)Index - 1);
|
||||
Sleep(250);
|
||||
}
|
||||
}
|
||||
@@ -317,7 +248,7 @@ public class Avatar
|
||||
{
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
// 剪裁出队伍区域
|
||||
var teamRa = region.DeriveCrop(AutoFightAssets.Instance.TeamRect);
|
||||
var teamRa = region.DeriveCrop(AutoFightContext.Instance.FightAssets.TeamRect);
|
||||
var blockX = NameRect.X + NameRect.Width * 2 - 10;
|
||||
var block = teamRa.DeriveCrop(new Rect(blockX, NameRect.Y, teamRa.Width - blockX, NameRect.Height * 2));
|
||||
// Cv2.ImWrite($"block_{Name}.png", block.SrcMat);
|
||||
@@ -340,7 +271,7 @@ public class Avatar
|
||||
else
|
||||
{
|
||||
// 剪裁出IndexRect区域
|
||||
var teamRa = region.DeriveCrop(AutoFightAssets.Instance.TeamRect);
|
||||
var teamRa = region.DeriveCrop(AutoFightContext.Instance.FightAssets.TeamRect);
|
||||
var blockX = NameRect.X + NameRect.Width * 2 - 10;
|
||||
var indexBlock = teamRa.DeriveCrop(new Rect(blockX + IndexRect.X, NameRect.Y + IndexRect.Y, IndexRect.Width, IndexRect.Height));
|
||||
// Cv2.ImWrite($"indexBlock_{Name}.png", indexBlock.SrcMat);
|
||||
@@ -368,7 +299,7 @@ public class Avatar
|
||||
return;
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
AutoFightContext.Instance.Simulator.LeftButtonClick();
|
||||
ms -= 200;
|
||||
Sleep(200, Ct);
|
||||
}
|
||||
@@ -390,7 +321,7 @@ public class Avatar
|
||||
{
|
||||
if (Name == "纳西妲")
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyDown);
|
||||
AutoFightContext.Instance.Simulator.KeyDown(User32.VK.VK_E);
|
||||
Sleep(300, Ct);
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
@@ -399,22 +330,22 @@ public class Avatar
|
||||
}
|
||||
|
||||
Sleep(300); // 持续操作不应该被cts取消
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyUp);
|
||||
AutoFightContext.Instance.Simulator.KeyUp(User32.VK.VK_E);
|
||||
}
|
||||
else if (Name == "坎蒂丝")
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyDown);
|
||||
AutoFightContext.Instance.Simulator.KeyDown(User32.VK.VK_E);
|
||||
Thread.Sleep(3000);
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyUp);
|
||||
AutoFightContext.Instance.Simulator.KeyUp(User32.VK.VK_E);
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.Hold);
|
||||
AutoFightContext.Instance.Simulator.LongKeyPress(User32.VK.VK_E);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyPress);
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_E);
|
||||
}
|
||||
|
||||
Sleep(200, Ct);
|
||||
@@ -426,7 +357,6 @@ public class Avatar
|
||||
{
|
||||
Logger.LogInformation(hold ? "{Name} 长按元素战技,cd:{Cd}" : "{Name} 点按元素战技,cd:{Cd}", Name, cd);
|
||||
// todo 把cd加入执行队列
|
||||
LastSkillTime = DateTime.UtcNow;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -439,9 +369,8 @@ public class Avatar
|
||||
/// </summary>
|
||||
public double GetSkillCurrentCd(ImageRegion imageRegion)
|
||||
{
|
||||
var eRa = imageRegion.DeriveCrop(AutoFightAssets.Instance.ECooldownRect);
|
||||
var eRaWhite = OpenCvCommonHelper.InRangeHsv(eRa.SrcMat, new Scalar(0, 0, 235), new Scalar(0, 25, 255));
|
||||
var text = OcrFactory.Paddle.OcrWithoutDetector(eRaWhite);
|
||||
var eRa = imageRegion.DeriveCrop(AutoFightContext.Instance.FightAssets.ERect);
|
||||
var text = OcrFactory.Paddle.Ocr(eRa.SrcGreyMat);
|
||||
return StringUtils.TryParseDouble(text);
|
||||
}
|
||||
|
||||
@@ -459,7 +388,7 @@ public class Avatar
|
||||
return;
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalBurst);
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_Q);
|
||||
Sleep(200, Ct);
|
||||
|
||||
var region = CaptureToRectArea();
|
||||
@@ -494,7 +423,7 @@ public class Avatar
|
||||
// /// </summary>
|
||||
// public double GetBurstCurrentCd(CaptureContent content)
|
||||
// {
|
||||
// var qRa = content.CaptureRectArea.Crop(AutoFightAssets.Instance.QRect);
|
||||
// var qRa = content.CaptureRectArea.Crop(AutoFightContext.Instance.FightAssets.QRect);
|
||||
// var text = OcrFactory.Paddle.Ocr(qRa.SrcGreyMat);
|
||||
// return StringUtils.TryParseDouble(text);
|
||||
// }
|
||||
@@ -514,9 +443,9 @@ public class Avatar
|
||||
ms = 200;
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyDown);
|
||||
AutoFightContext.Instance.Simulator.RightButtonDown();
|
||||
Sleep(ms); // 冲刺不能被cts取消
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyUp);
|
||||
AutoFightContext.Instance.Simulator.RightButtonUp();
|
||||
}
|
||||
|
||||
public void Walk(string key, int ms)
|
||||
@@ -529,19 +458,19 @@ public class Avatar
|
||||
User32.VK vk = User32.VK.VK_NONAME;
|
||||
if (key == "w")
|
||||
{
|
||||
vk = GIActions.MoveForward.ToActionKey().ToVK();
|
||||
vk = User32.VK.VK_W;
|
||||
}
|
||||
else if (key == "s")
|
||||
{
|
||||
vk = GIActions.MoveBackward.ToActionKey().ToVK();
|
||||
vk = User32.VK.VK_S;
|
||||
}
|
||||
else if (key == "a")
|
||||
{
|
||||
vk = GIActions.MoveLeft.ToActionKey().ToVK();
|
||||
vk = User32.VK.VK_A;
|
||||
}
|
||||
else if (key == "d")
|
||||
{
|
||||
vk = GIActions.MoveRight.ToActionKey().ToVK();
|
||||
vk = User32.VK.VK_D;
|
||||
}
|
||||
|
||||
if (vk == User32.VK.VK_NONAME)
|
||||
@@ -549,9 +478,9 @@ public class Avatar
|
||||
return;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyDown(vk);
|
||||
AutoFightContext.Instance.Simulator.KeyDown(vk);
|
||||
Sleep(ms); // 行走不能被cts取消
|
||||
Simulation.SendInput.Keyboard.KeyUp(vk);
|
||||
AutoFightContext.Instance.Simulator.KeyUp(vk);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -578,7 +507,7 @@ public class Avatar
|
||||
/// </summary>
|
||||
public void Jump()
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_SPACE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -594,7 +523,7 @@ public class Avatar
|
||||
if (Name == "那维莱特")
|
||||
{
|
||||
var dpi = TaskContext.Instance().DpiScale;
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack, KeyType.KeyDown);
|
||||
AutoFightContext.Instance.Simulator.LeftButtonDown();
|
||||
while (ms >= 0)
|
||||
{
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
@@ -607,13 +536,13 @@ public class Avatar
|
||||
Sleep(50); // 持续操作不应该被cts取消
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack, KeyType.KeyUp);
|
||||
AutoFightContext.Instance.Simulator.LeftButtonUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack, KeyType.KeyDown);
|
||||
AutoFightContext.Instance.Simulator.LeftButtonDown();
|
||||
Sleep(ms); // 持续操作不应该被cts取消
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack, KeyType.KeyUp);
|
||||
AutoFightContext.Instance.Simulator.LeftButtonUp();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,11 +551,11 @@ public class Avatar
|
||||
key = key.ToLower();
|
||||
if (key == "left")
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonDown();
|
||||
AutoFightContext.Instance.Simulator.LeftButtonDown();
|
||||
}
|
||||
else if (key == "right")
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
AutoFightContext.Instance.Simulator.RightButtonDown();
|
||||
}
|
||||
else if (key == "middle")
|
||||
{
|
||||
@@ -639,11 +568,11 @@ public class Avatar
|
||||
key = key.ToLower();
|
||||
if (key == "left")
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
AutoFightContext.Instance.Simulator.LeftButtonUp();
|
||||
}
|
||||
else if (key == "right")
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
AutoFightContext.Instance.Simulator.RightButtonUp();
|
||||
}
|
||||
else if (key == "middle")
|
||||
{
|
||||
@@ -656,11 +585,11 @@ public class Avatar
|
||||
key = key.ToLower();
|
||||
if (key == "left")
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
AutoFightContext.Instance.Simulator.LeftButtonClick();
|
||||
}
|
||||
else if (key == "right")
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonClick();
|
||||
AutoFightContext.Instance.Simulator.RightButtonClick();
|
||||
}
|
||||
else if (key == "middle")
|
||||
{
|
||||
@@ -676,78 +605,18 @@ public class Avatar
|
||||
public void KeyDown(string key)
|
||||
{
|
||||
var vk = User32Helper.ToVk(key);
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonDown();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonDown(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyDown(vk);
|
||||
break;
|
||||
}
|
||||
AutoFightContext.Instance.Simulator.KeyDown(vk);
|
||||
}
|
||||
|
||||
public void KeyUp(string key)
|
||||
{
|
||||
var vk = User32Helper.ToVk(key);
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonUp(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyUp(vk);
|
||||
break;
|
||||
}
|
||||
AutoFightContext.Instance.Simulator.KeyUp(vk);
|
||||
}
|
||||
|
||||
public void KeyPress(string key)
|
||||
{
|
||||
var vk = User32Helper.ToVk(key);
|
||||
switch (key)
|
||||
{
|
||||
case "VK_LBUTTON":
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
break;
|
||||
case "VK_RBUTTON":
|
||||
Simulation.SendInput.Mouse.RightButtonClick();
|
||||
break;
|
||||
case "VK_MBUTTON":
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
break;
|
||||
case "VK_XBUTTON1":
|
||||
Simulation.SendInput.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
case "VK_XBUTTON2":
|
||||
Simulation.SendInput.Mouse.XButtonClick(0x0001);
|
||||
break;
|
||||
default:
|
||||
Simulation.SendInput.Keyboard.KeyPress(vk);
|
||||
break;
|
||||
}
|
||||
AutoFightContext.Instance.Simulator.KeyPress(vk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
@@ -32,7 +31,7 @@ public class CombatScenes : IDisposable
|
||||
/// <summary>
|
||||
/// 当前配队
|
||||
/// </summary>
|
||||
public Avatar[] Avatars { get; set; } = [];
|
||||
public Avatar[] Avatars { get; set; } = Array.Empty<Avatar>();
|
||||
|
||||
public Dictionary<string, Avatar> AvatarMap { get; set; } = [];
|
||||
|
||||
@@ -52,7 +51,6 @@ public class CombatScenes : IDisposable
|
||||
/// <param name="imageRegion">完整游戏画面的捕获截图</param>
|
||||
public CombatScenes InitializeTeam(ImageRegion imageRegion)
|
||||
{
|
||||
AssertUtils.CheckGameResolution();
|
||||
// 优先取配置
|
||||
if (!string.IsNullOrEmpty(TaskContext.Instance().Config.AutoFightConfig.TeamNames))
|
||||
{
|
||||
@@ -71,7 +69,6 @@ public class CombatScenes : IDisposable
|
||||
{
|
||||
throw new Exception("当前处于联机状态,但是队伍人数超过4人,无法识别");
|
||||
}
|
||||
|
||||
// 联机状态下判断
|
||||
var onePRa = imageRegion.Find(AutoFightAssets.Instance.OnePRa);
|
||||
var p = "p";
|
||||
@@ -166,18 +163,18 @@ public class CombatScenes : IDisposable
|
||||
if (result.TopClass.Name.Name.StartsWith("Qin") || result.TopClass.Name.Name.Contains("Costume"))
|
||||
{
|
||||
// 降低琴和衣装角色的识别率要求
|
||||
if (result.TopClass.Confidence < 0.51)
|
||||
if (result.TopClass.Confidence < 0.6)
|
||||
{
|
||||
Cv2.ImWrite(@"log\avatar_side_classify_error.png", src.ToMat());
|
||||
throw new Exception($"无法识别第{index}位角色,置信度{result.TopClass.Confidence:F1},结果:{result.TopClass.Name.Name}。请重新阅读 BetterGI 文档中的《快速上手》!");
|
||||
throw new Exception($"无法识别第{index}位角色,置信度{result.TopClass.Confidence},结果:{result.TopClass.Name.Name}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.TopClass.Confidence < 0.7)
|
||||
if (result.TopClass.Confidence < 0.8)
|
||||
{
|
||||
Cv2.ImWrite(@"log\avatar_side_classify_error.png", src.ToMat());
|
||||
throw new Exception($"无法识别第{index}位角色,置信度{result.TopClass.Confidence:F1},结果:{result.TopClass.Name.Name}。请重新阅读 BetterGI 文档中的《快速上手》!");
|
||||
throw new Exception($"无法识别第{index}位角色,置信度{result.TopClass.Confidence},结果:{result.TopClass.Name.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +215,7 @@ public class CombatScenes : IDisposable
|
||||
{
|
||||
if (avatarIndexRectList == null && ExpectedTeamAvatarNum == 4)
|
||||
{
|
||||
avatarIndexRectList = AutoFightAssets.Instance.AvatarIndexRectList;
|
||||
avatarIndexRectList = AutoFightContext.Instance.FightAssets.AvatarIndexRectList;
|
||||
}
|
||||
|
||||
if (avatarIndexRectList == null)
|
||||
@@ -248,24 +245,6 @@ public class CombatScenes : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void AfterTask()
|
||||
{
|
||||
// 释放所有按键
|
||||
Simulation.ReleaseAllKey();
|
||||
|
||||
var mwk = SelectAvatar("玛薇卡");
|
||||
if (mwk != null)
|
||||
{
|
||||
foreach (var avatar in Avatars)
|
||||
{
|
||||
if (avatar.Name != "玛薇卡")
|
||||
{
|
||||
avatar.Switch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Avatar? SelectAvatar(string name)
|
||||
{
|
||||
return AvatarMap.GetValueOrDefault(name);
|
||||
@@ -288,7 +267,7 @@ public class CombatScenes : IDisposable
|
||||
}
|
||||
|
||||
// 剪裁出队伍区域
|
||||
var teamRa = content.CaptureRectArea.DeriveCrop(AutoFightAssets.Instance.TeamRectNoIndex);
|
||||
var teamRa = content.CaptureRectArea.DeriveCrop(AutoFightContext.Instance.FightAssets.TeamRectNoIndex);
|
||||
// 过滤出白色
|
||||
var hsvFilterMat = OpenCvCommonHelper.InRangeHsv(teamRa.SrcMat, new Scalar(0, 0, 210), new Scalar(255, 30, 255));
|
||||
|
||||
@@ -323,10 +302,10 @@ public class CombatScenes : IDisposable
|
||||
{
|
||||
// 流浪者特殊处理
|
||||
// 4人以上的队伍,不支持流浪者的识别
|
||||
var wanderer = rectArea.Find(AutoFightAssets.Instance.WandererIconRa);
|
||||
var wanderer = rectArea.Find(AutoFightContext.Instance.FightAssets.WandererIconRa);
|
||||
if (wanderer.IsEmpty())
|
||||
{
|
||||
wanderer = rectArea.Find(AutoFightAssets.Instance.WandererIconNoActiveRa);
|
||||
wanderer = rectArea.Find(AutoFightContext.Instance.FightAssets.WandererIconNoActiveRa);
|
||||
}
|
||||
|
||||
if (wanderer.IsEmpty())
|
||||
@@ -401,4 +380,4 @@ public class CombatScenes : IDisposable
|
||||
{
|
||||
_predictor.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,74 +27,72 @@ public class CombatCommand
|
||||
Method = Method.GetEnumByCode(method);
|
||||
|
||||
var parameters = command.Substring(startIndex + 1, endIndex - startIndex - 1);
|
||||
Args = [..parameters.Split(',', StringSplitOptions.TrimEntries)];
|
||||
|
||||
Args = new List<string>(parameters.Split(',', StringSplitOptions.TrimEntries));
|
||||
// 校验参数
|
||||
if (Method == Method.Walk)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 2, "walk方法必须有两个入参,第一个参数是方向,第二个参数是行走时间。例:walk(s, 0.2)");
|
||||
var s = double.Parse(Args[1]);
|
||||
AssertUtils.IsTrue(s > 0, "行走时间必须大于0");
|
||||
}
|
||||
else if (Method == Method.W || Method == Method.A || Method == Method.S || Method == Method.D)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 1, "w/a/s/d方法必须有一个入参,代表行走时间。例:d(0.5)");
|
||||
}
|
||||
else if (Method == Method.MoveBy)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 2, "moveby方法必须有两个入参,分别是x和y。例:moveby(100, 100))");
|
||||
}
|
||||
else if (Method == Method.KeyDown || Method == Method.KeyUp || Method == Method.KeyPress)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 1, $"{Method.Alias[0]}方法必须有一个入参,代表按键");
|
||||
try
|
||||
{
|
||||
User32Helper.ToVk(Args[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]} 不合法");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Method = Method.GetEnumByCode(command);
|
||||
Args = [];
|
||||
}
|
||||
|
||||
// 校验参数
|
||||
if (Method == Method.Walk)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 2, "walk方法必须有两个入参,第一个参数是方向,第二个参数是行走时间。例:walk(s, 0.2)");
|
||||
var s = double.Parse(Args[1]);
|
||||
AssertUtils.IsTrue(s > 0, "行走时间必须大于0");
|
||||
}
|
||||
else if (Method == Method.W || Method == Method.A || Method == Method.S || Method == Method.D)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 1, "w/a/s/d方法必须有一个入参,代表行走时间。例:d(0.5)");
|
||||
}
|
||||
else if (Method == Method.MoveBy)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 2, "moveby方法必须有两个入参,分别是x和y。例:moveby(100, 100))");
|
||||
}
|
||||
else if (Method == Method.KeyDown || Method == Method.KeyUp || Method == Method.KeyPress)
|
||||
{
|
||||
AssertUtils.IsTrue(Args.Count == 1, $"{Method.Alias[0]}方法必须有一个入参,代表按键");
|
||||
try
|
||||
{
|
||||
User32Helper.ToVk(Args[0]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"{Method.Alias[0]}方法的入参必须是VirtualKeyCodes枚举中的值,当前入参 {Args[0]} 不合法");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(CombatScenes combatScenes)
|
||||
{
|
||||
// 如果是当前角色
|
||||
Avatar? avatar;
|
||||
if (Name == CombatScriptParser.CurrentAvatarName)
|
||||
{
|
||||
// 如果是当前角色,不进行角色切换
|
||||
avatar = combatScenes.Avatars[0]; // 随便取一个角色
|
||||
}
|
||||
else
|
||||
{
|
||||
// 其余情况要进行角色切换
|
||||
avatar = combatScenes.SelectAvatar(Name);
|
||||
if (avatar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 非宏类脚本,等待切换角色成功
|
||||
if (Method != Method.Wait
|
||||
&& Method != Method.MouseDown
|
||||
&& Method != Method.MouseUp
|
||||
&& Method != Method.Click
|
||||
&& Method != Method.MoveBy
|
||||
&& Method != Method.KeyDown
|
||||
&& Method != Method.KeyUp
|
||||
&& Method != Method.KeyPress)
|
||||
{
|
||||
avatar.Switch();
|
||||
}
|
||||
}
|
||||
|
||||
if (avatar == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 非宏类脚本,等待切换角色成功
|
||||
if (Method != Method.Wait
|
||||
&& Method != Method.MouseDown
|
||||
&& Method != Method.MouseUp
|
||||
&& Method != Method.Click
|
||||
&& Method != Method.MoveBy
|
||||
&& Method != Method.KeyDown
|
||||
&& Method != Method.KeyUp
|
||||
&& Method != Method.KeyPress)
|
||||
{
|
||||
avatar.Switch();
|
||||
}
|
||||
|
||||
Execute(avatar);
|
||||
}
|
||||
|
||||
|
||||
@@ -728,13 +728,11 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
{
|
||||
NewRetry.Do(() =>
|
||||
{
|
||||
TaskControl.TrySuspend();
|
||||
if (IsEnabled && !SystemControl.IsGenshinImpactActiveByProcess())
|
||||
{
|
||||
_logger.LogWarning("当前获取焦点的窗口不是原神,暂停");
|
||||
throw new RetryException("当前获取焦点的窗口不是原神");
|
||||
}
|
||||
|
||||
}, TimeSpan.FromSeconds(1), 100);
|
||||
CheckFishingUserInterface(_currContent);
|
||||
Thread.Sleep(millisecondsTimeout);
|
||||
|
||||
@@ -1787,75 +1787,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1214,
|
||||
"nameEn": "mualani",
|
||||
"type": "character",
|
||||
"name": "玛拉妮",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "水元素",
|
||||
"weapon": "法器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "cooling_treatment",
|
||||
"name": "降温处理",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "surfshark_wavebreaker",
|
||||
"name": "踏鲨破浪",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "boomsharkalaka",
|
||||
"name": "爆瀑飞弹",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1301,
|
||||
"nameEn": "diluc",
|
||||
@@ -2776,83 +2707,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1314,
|
||||
"nameEn": "arlecchino",
|
||||
"type": "character",
|
||||
"name": "阿蕾奇诺",
|
||||
"hp": 10,
|
||||
"energy": 3,
|
||||
"element": "火元素",
|
||||
"weapon": "长柄武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "invitation_to_a_beheading",
|
||||
"name": "斩首之邀",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "all_is_ash",
|
||||
"name": "万相化灰",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "balemoon_rising",
|
||||
"name": "厄月将升",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1103,
|
||||
"nameEn": "pyro",
|
||||
"type": "火元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "the_balemoon_alone_may_know",
|
||||
"name": "唯厄月可知晓",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1401,
|
||||
"nameEn": "fischl",
|
||||
@@ -3628,75 +3482,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1412,
|
||||
"nameEn": "clorinde",
|
||||
"type": "character",
|
||||
"name": "克洛琳德",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "雷元素",
|
||||
"weapon": "单手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "oath_of_hunting_shadows",
|
||||
"name": "逐影之誓",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "hunters_vigil",
|
||||
"name": "狩夜之巡",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "last_lightfall",
|
||||
"name": "残光将终",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1501,
|
||||
"nameEn": "sucrose",
|
||||
@@ -5598,75 +5383,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1709,
|
||||
"nameEn": "kinich",
|
||||
"type": "character",
|
||||
"name": "基尼奇",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "草元素",
|
||||
"weapon": "双手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "nightsun_style",
|
||||
"name": "夜阳斗技",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "canopy_hunter_riding_high",
|
||||
"name": "悬猎·游骋高狩",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "hail_to_the_almighty_dragonlord",
|
||||
"name": "向伟大圣龙致意",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2101,
|
||||
"nameEn": "fatui_cryo_cicin_mage",
|
||||
@@ -6579,7 +6295,7 @@
|
||||
"nameEn": "emperor_of_fire_and_iron",
|
||||
"type": "character",
|
||||
"name": "铁甲熔火帝皇",
|
||||
"hp": 5,
|
||||
"hp": 6,
|
||||
"energy": 2,
|
||||
"element": "火元素",
|
||||
"weapon": "其他武器",
|
||||
@@ -7504,75 +7220,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2603,
|
||||
"nameEn": "golden_wolflord",
|
||||
"type": "character",
|
||||
"name": "黄金王兽",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "岩元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "wolflords_strike",
|
||||
"name": "王狼直击",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "howling_riftcall",
|
||||
"name": "兽境轰召",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "golden_cankerbind",
|
||||
"name": "黄金侵绞",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2701,
|
||||
"nameEn": "jadeplume_terrorshroom",
|
||||
@@ -7803,5 +7450,74 @@
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 4608,
|
||||
"nameEn": "golden_wolflord",
|
||||
"type": "character",
|
||||
"name": "黄金王兽",
|
||||
"hp": 40,
|
||||
"energy": 2,
|
||||
"element": "岩元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "wolflords_strike",
|
||||
"name": "王狼直击",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "howling_riftcall",
|
||||
"name": "兽境轰召",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "golden_cankerbind",
|
||||
"name": "黄金侵绞",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,7 +1,5 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
@@ -11,17 +9,9 @@ public class AutoGeniusInvokationTask(GeniusInvokationTaskParam taskParam) : ISo
|
||||
|
||||
public Task Start(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 读取策略信息
|
||||
var duel = ScriptParser.Parse(taskParam.StrategyContent);
|
||||
duel.Run(ct);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
TaskControl.Logger.LogDebug(e, "执行自动七圣召唤任务异常");
|
||||
TaskControl.Logger.LogError("执行自动七圣召唤任务异常:{Exception}", e.Message);
|
||||
}
|
||||
// 读取策略信息
|
||||
var duel = ScriptParser.Parse(taskParam.StrategyContent);
|
||||
duel.Run(ct);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,13 +107,12 @@ public class GeniusInvokationControl
|
||||
{
|
||||
return;
|
||||
}
|
||||
TaskControl.TrySuspend();
|
||||
|
||||
if (!SystemControl.IsGenshinImpactActiveByProcess())
|
||||
{
|
||||
_logger.LogWarning("当前获取焦点的窗口不是原神,暂停");
|
||||
throw new RetryException("当前获取焦点的窗口不是原神");
|
||||
}
|
||||
|
||||
}, TimeSpan.FromSeconds(1), 100);
|
||||
|
||||
if (_ct is { IsCancellationRequested: true })
|
||||
|
||||
@@ -10,7 +10,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
|
||||
@@ -58,13 +57,12 @@ public class Duel
|
||||
|
||||
public void Run(CancellationToken ct)
|
||||
{
|
||||
LogScreenResolution();
|
||||
try
|
||||
{
|
||||
Notify.Event(NotificationEvent.TcgStart).Success("自动七胜召唤启动");
|
||||
|
||||
AutoGeniusInvokationAssets.DestroyInstance();
|
||||
|
||||
|
||||
LogScreenResolution();
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Started().Build()); // TODO 需要移动
|
||||
GeniusInvokationControl.GetInstance().Init(ct);
|
||||
|
||||
// 对局准备 选择初始手牌
|
||||
@@ -290,12 +288,14 @@ public class Duel
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Cancelled().Build());
|
||||
throw;
|
||||
}
|
||||
catch (NormalEndException ex)
|
||||
{
|
||||
_logger.LogInformation("对局结束");
|
||||
// throw;
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Success().Build());
|
||||
throw;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
@@ -303,10 +303,9 @@ public class Duel
|
||||
{
|
||||
_logger.LogError(ex.StackTrace);
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Failure().Build());
|
||||
throw;
|
||||
}
|
||||
|
||||
Notify.Event(NotificationEvent.TcgEnd).Success("自动七胜召唤结束");
|
||||
}
|
||||
|
||||
private HashSet<ElementalType> PredictionDiceType()
|
||||
@@ -438,7 +437,6 @@ public class Duel
|
||||
if (gameScreenSize.Width != 1920 || gameScreenSize.Height != 1080)
|
||||
{
|
||||
_logger.LogWarning("游戏窗口分辨率不是 1920x1080 !当前分辨率为 {Width}x{Height} , 非 1920x1080 分辨率的游戏可能无法正常使用自动七圣召唤 !", gameScreenSize.Width, gameScreenSize.Height);
|
||||
throw new System.Exception("游戏窗口分辨率不是 1920x1080");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class ScriptParser
|
||||
var characterAndSkill = line.Split('{');
|
||||
|
||||
var parts = characterAndSkill[0].Split('=');
|
||||
character.Index = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(parts[0].Trim(), ""));
|
||||
character.Index = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(parts[0], ""));
|
||||
MyAssert(character.Index >= 1 && character.Index <= 3, "角色序号必须在1-3之间");
|
||||
|
||||
if (parts[1].Contains('|'))
|
||||
|
||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 505 B |
|
Before Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
@@ -1,84 +0,0 @@
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame.Assets;
|
||||
|
||||
public class AutoMusicAssets : BaseAssets<AutoMusicAssets>
|
||||
{
|
||||
public RecognitionObject UiLeftTopAlbumIcon;
|
||||
public RecognitionObject BtnPause;
|
||||
public RecognitionObject AlbumMusicComplate;
|
||||
public RecognitionObject BtnList;
|
||||
public RecognitionObject MusicCanorusLevel1;
|
||||
public RecognitionObject MusicCanorusLevel2;
|
||||
public RecognitionObject MusicCanorusLevel3;
|
||||
public RecognitionObject MusicCanorusLevel4;
|
||||
|
||||
private AutoMusicAssets()
|
||||
{
|
||||
UiLeftTopAlbumIcon = new RecognitionObject
|
||||
{
|
||||
Name = "UiLeftTopAlbumIcon",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "ui_left_top_album_icon.png"),
|
||||
RegionOfInterest = new Rect(0, 0, (int)(150 * AssetScale), (int)(120 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
BtnPause = new RecognitionObject
|
||||
{
|
||||
Name = "BtnPause",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "btn_pause.png"),
|
||||
RegionOfInterest = CaptureRect.CutRightTop(0.2, 0.2),
|
||||
}.InitTemplate();
|
||||
AlbumMusicComplate = new RecognitionObject
|
||||
{
|
||||
Name = "AlbumMusicComplate",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "album_music_complate.png"),
|
||||
RegionOfInterest = new Rect( (int)(900 * AssetScale),(int)(320 * AssetScale), (int)(100 * AssetScale), (int)(80 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
BtnList = new RecognitionObject
|
||||
{
|
||||
Name = "BtnList",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "btn_list.png"),
|
||||
RegionOfInterest = CaptureRect.CutRightBottom(0.4, 0.2),
|
||||
}.InitTemplate();
|
||||
|
||||
var musicCanorusTemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "music_canorus.png");
|
||||
MusicCanorusLevel1 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel1",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(430 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel2 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel2",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(520 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel3 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel3",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(610 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel4 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel4",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(690 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoMusicGame.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.Service.Notification.Model.Enum;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
/// <summary>
|
||||
/// 自动音乐专辑
|
||||
/// </summary>
|
||||
public class AutoAlbumTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
{
|
||||
public string Name => "自动音游专辑";
|
||||
|
||||
private AutoMusicGameTask _autoMusicGameTask = new AutoMusicGameTask(taskParam);
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
AutoMusicGameTask.Init();
|
||||
Notify.Event(NotificationEvent.AlbumStart).Success("自动音游专辑启动");
|
||||
Logger.LogInformation("开始自动演奏整个专辑未完成的音乐");
|
||||
await StartOneAlbum(ct);
|
||||
Notify.Event(NotificationEvent.AlbumEnd).Success("自动音游专辑结束");
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogError("手动取消任务 - {Msg}", e.Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError("自动音乐专辑任务异常:{Msg}", e.Message);
|
||||
Notify.Event(NotificationEvent.AlbumError).Error("自动音游专辑异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task StartOneAlbum(CancellationToken ct)
|
||||
{
|
||||
using var ra1 = CaptureToRectArea();
|
||||
using var iconRa = ra1.Find(AutoMusicAssets.Instance.UiLeftTopAlbumIcon);
|
||||
if (!iconRa.IsExist())
|
||||
{
|
||||
throw new Exception("当前未处于主题专辑界面,请在专辑界面运行本任务。注意全部歌曲列表页面无法运行本任务!");
|
||||
}
|
||||
else
|
||||
{
|
||||
// OCR 后再次判断,区分是否是全部歌曲页面
|
||||
var ocrRes = ra1.DeriveCrop(iconRa.Right, iconRa.Top, ra1.Width * 0.16, iconRa.Height).FindMulti(RecognitionObject.OcrThis);
|
||||
if (ocrRes.Any(region => region.Text.Contains("全部")))
|
||||
{
|
||||
throw new Exception("当前在全部歌曲页面,此页面无法运行本任务。请返回到主界面选择专辑列表中以国家为主题的专辑页!");
|
||||
}
|
||||
}
|
||||
|
||||
var musicLevel = TaskContext.Instance().Config.AutoMusicGameConfig.MusicLevel;
|
||||
if (string.IsNullOrEmpty(musicLevel))
|
||||
{
|
||||
musicLevel = "传说";
|
||||
}
|
||||
|
||||
Logger.LogInformation("自动音游乐曲难度等级:{Text}", musicLevel);
|
||||
|
||||
// 遍历4个难度等级
|
||||
var defaultDifficultyLevels = new[]
|
||||
{
|
||||
("普通", 480, 600, AutoMusicAssets.Instance.MusicCanorusLevel1),
|
||||
("困难", 800, 600, AutoMusicAssets.Instance.MusicCanorusLevel2),
|
||||
("大师", 1150, 600, AutoMusicAssets.Instance.MusicCanorusLevel3),
|
||||
("传说", 1400, 600, AutoMusicAssets.Instance.MusicCanorusLevel4)
|
||||
};
|
||||
|
||||
var difficultyLevels = defaultDifficultyLevels;
|
||||
if (musicLevel != "所有")
|
||||
{
|
||||
difficultyLevels = [Array.Find(defaultDifficultyLevels, level => level.Item1 == musicLevel)];
|
||||
}
|
||||
|
||||
foreach (var (difficultyName, xPos, yPos, canorusAsset) in difficultyLevels)
|
||||
{
|
||||
Logger.LogInformation("开始演奏{Difficulty}难度的乐曲", difficultyName);
|
||||
|
||||
// 每个难度12首曲子
|
||||
for (int i = 0; i < 13; i++)
|
||||
{
|
||||
if (TaskContext.Instance().Config.AutoMusicGameConfig.MustCanorusLevel)
|
||||
{
|
||||
using var canoraRa = CaptureToRectArea().Find(canorusAsset);
|
||||
if (canoraRa.IsExist())
|
||||
{
|
||||
Logger.LogInformation("乐曲{Num} - {Difficulty}级别:已完成【大音天籁】,切换下一首", i + 1, difficultyName);
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.LogInformation("第{Num}首{Difficulty}难度的乐曲:{Message}", i + 1, difficultyName, "没有完成【大音天籁】");
|
||||
}
|
||||
else
|
||||
{
|
||||
using var doneRa = CaptureToRectArea().Find(AutoMusicAssets.Instance.AlbumMusicComplate);
|
||||
if (doneRa.IsExist())
|
||||
{
|
||||
Logger.LogInformation("当前乐曲{Num}所有奖励已领取,切换下一首", i + 1);
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.LogInformation("当前乐曲{Num}存在未领取奖励,前往演奏", i + 1);
|
||||
}
|
||||
|
||||
|
||||
// 点击确认按钮
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(800, ct);
|
||||
|
||||
// 选择难度
|
||||
GameCaptureRegion.GameRegion1080PPosClick(xPos, yPos);
|
||||
await Delay(200, ct);
|
||||
|
||||
// 开始演奏
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(500, ct);
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
ct.Register(cts.Cancel);
|
||||
|
||||
// 演奏结束检查任务
|
||||
var checkTask = Task.Run(async () =>
|
||||
{
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
{
|
||||
await Delay(5000, ct); // 每5秒检查一次
|
||||
using var listRa = CaptureToRectArea().Find(AutoMusicAssets.Instance.BtnList);
|
||||
if (listRa.IsExist())
|
||||
{
|
||||
Logger.LogDebug("检测到返回列表按钮,演奏结束");
|
||||
listRa.Click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 演奏任务
|
||||
var musicTask = _autoMusicGameTask.StartWithOutInit(cts.Token);
|
||||
|
||||
// 等待任意一个任务完成
|
||||
await Task.WhenAny(checkTask, musicTask);
|
||||
await cts.CancelAsync();
|
||||
|
||||
Logger.LogInformation("第{Num}首{Difficulty}难度乐曲演奏完成", i + 1, difficultyName);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await Bv.WaitUntilFound(AutoMusicAssets.Instance.UiLeftTopAlbumIcon, ct);
|
||||
Logger.LogDebug("切换到下一首乐曲");
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
}
|
||||
|
||||
Logger.LogInformation("完成{Difficulty}难度所有乐曲的演奏", difficultyName);
|
||||
}
|
||||
|
||||
Logger.LogInformation("当前专辑所有乐曲演奏结束");
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 千音雅集配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class AutoMusicGameConfig : ObservableObject
|
||||
{
|
||||
// 自动达到大音天籁的级别
|
||||
[ObservableProperty]
|
||||
private bool _mustCanorusLevel = false;
|
||||
|
||||
// 乐曲级别
|
||||
[ObservableProperty]
|
||||
private string _musicLevel = "";
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -16,73 +15,47 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
{
|
||||
public string Name => "自动音游";
|
||||
|
||||
|
||||
// private readonly ConcurrentDictionary<User32.VK, int> _keyX = new()
|
||||
// {
|
||||
// [User32.VK.VK_A] = 417,
|
||||
// [User32.VK.VK_S] = 632,
|
||||
// [User32.VK.VK_D] = 846,
|
||||
// [User32.VK.VK_J] = 1065,
|
||||
// [User32.VK.VK_K] = 1282,
|
||||
// [User32.VK.VK_L] = 1500
|
||||
// };
|
||||
//
|
||||
// private readonly int _keyY = 916;
|
||||
|
||||
|
||||
private readonly ConcurrentDictionary<User32.VK, int> _keyX = new()
|
||||
{
|
||||
[User32.VK.VK_A] = 417,
|
||||
[User32.VK.VK_S] = 628,
|
||||
[User32.VK.VK_D] = 844,
|
||||
[User32.VK.VK_J] = 1061,
|
||||
[User32.VK.VK_K] = 1277,
|
||||
[User32.VK.VK_L] = 1493
|
||||
[User32.VK.VK_S] = 632,
|
||||
[User32.VK.VK_D] = 846,
|
||||
[User32.VK.VK_J] = 1065,
|
||||
[User32.VK.VK_K] = 1282,
|
||||
[User32.VK.VK_L] = 1500
|
||||
};
|
||||
|
||||
private readonly int _keyY = 921;
|
||||
private readonly int _keyY = 916;
|
||||
|
||||
private readonly IntPtr _hWnd = TaskContext.Instance().GameHandle;
|
||||
|
||||
public async Task Start(CancellationToken ct)
|
||||
public Task Start(CancellationToken ct)
|
||||
{
|
||||
Init();
|
||||
await StartWithOutInit(ct);
|
||||
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(taskFactory.StartNew(() => DoWhitePressWin32(ct, keyValuePair.Key, new Point(x, y))));
|
||||
}
|
||||
|
||||
Task.WaitAll([.. taskList]);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task StartWithOutInit(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.LogInformation("开始自动演奏");
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
// var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(Task.Run(async () => await DoWhitePressWin32(ct, keyValuePair.Key, new Point(x, y)), ct));
|
||||
}
|
||||
|
||||
await Task.WhenAll(taskList);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Simulation.ReleaseAllKey();
|
||||
Logger.LogInformation("结束自动演奏");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoWhitePressWin32(CancellationToken ct, User32.VK key, Point point)
|
||||
private void DoWhitePressWin32(CancellationToken ct, User32.VK key, Point point)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(5, ct);
|
||||
Thread.Sleep(10);
|
||||
// Stopwatch sw = new();
|
||||
// sw.Start();
|
||||
var hdc = User32.GetDC(_hWnd);
|
||||
@@ -94,7 +67,7 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
KeyDown(key);
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(5, ct);
|
||||
Thread.Sleep(10);
|
||||
hdc = User32.GetDC(_hWnd);
|
||||
c = Gdi32.GetPixel(hdc, point.X, point.Y);
|
||||
Gdi32.DeleteDC(hdc);
|
||||
@@ -103,7 +76,6 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KeyUp(key);
|
||||
}
|
||||
|
||||
@@ -112,121 +84,6 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
}
|
||||
}
|
||||
|
||||
// private async Task DoWhitePressWin32Default(CancellationToken ct, User32.VK key, Point point)
|
||||
// {
|
||||
// while (!ct.IsCancellationRequested)
|
||||
// {
|
||||
// await Task.Delay(10, ct);
|
||||
// var c = GetPixel(point.X, point.Y);
|
||||
//
|
||||
// if (c.G < 220)
|
||||
// {
|
||||
// KeyDown(key);
|
||||
// while (!ct.IsCancellationRequested)
|
||||
// {
|
||||
// Thread.Sleep(10);
|
||||
// c = GetPixel(point.X, point.Y);
|
||||
// if (c.G >= 230 && c.G != 255)
|
||||
// {
|
||||
// if (point.X == 417)
|
||||
// {
|
||||
// Debug.WriteLine("打断颜色:" + c.R + "," + c.G + "," + c.B);
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// KeyUp(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// private async Task DoWhitePressWin32Default(CancellationToken ct, User32.VK key, Point point)
|
||||
// {
|
||||
// while (!ct.IsCancellationRequested)
|
||||
// {
|
||||
// await Task.Delay(5, ct);
|
||||
// var color = GetPixel(point.X, point.Y);
|
||||
// int r = color.R, g = color.G, b = color.B;
|
||||
//
|
||||
// if (r >= 140 && r <= 255 && g >= 100 && g <= 170 && b >= 230 && b <= 255)
|
||||
// {
|
||||
// // 按下按键
|
||||
// KeyDown(key);
|
||||
//
|
||||
// int z1 = 0;
|
||||
// while (z1 < 3)
|
||||
// {
|
||||
// await Task.Delay(5, ct);
|
||||
// color = GetPixel(point.X, point.Y);
|
||||
// int r1 = color.R, g1 = color.G, b1 = color.B;
|
||||
// var color2 = GetPixel(point.X + 2, point.Y + 2);
|
||||
// int r11 = color2.R, g11 = color2.G, b11 = color2.B;
|
||||
//
|
||||
// if ((r1 >= 140 && r1 <= 255 && g1 >= 100 && g1 <= 170) || (r11 >= 140 && r11 <= 255 && g11 >= 100 && g11 <= 170))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// z1++;
|
||||
// }
|
||||
//
|
||||
// Console.WriteLine($"{key} purple1 {r} {g} {b}");
|
||||
//
|
||||
// int z2 = 0;
|
||||
// while (z2 < 10)
|
||||
// {
|
||||
// await Task.Delay(5, ct);
|
||||
// color = GetPixel(point.X, point.Y);
|
||||
// int r1 = color.R, g1 = color.G, b1 = color.B;
|
||||
// var color2 = GetPixel(point.X + 2, point.Y + 2);
|
||||
// int r11 = color2.R, g11 = color2.G, b11 = color2.B;
|
||||
//
|
||||
// if (g1 >= 100 && g1 <= 170 || g11 >= 100 && g11 <= 170)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// z2++;
|
||||
// }
|
||||
//
|
||||
// Console.WriteLine($"{key} purple - 紫键结束 {r} {g} {b}");
|
||||
// KeyUp(key);
|
||||
// }
|
||||
//
|
||||
// if (r >= 230 && r <= 255 && g >= 170 && g <= 210 && b >= 50 && b <= 120)
|
||||
// {
|
||||
// KeyDown(key);
|
||||
//
|
||||
// var color2 = GetPixel(point.X, point.Y);
|
||||
// int r2 = color2.R, g2 = color2.G, b2 = color2.B;
|
||||
//
|
||||
//
|
||||
// while (g2 >= 170 && g2 <= 210 && b2 >= 50 && b2 <= 120)
|
||||
// {
|
||||
//
|
||||
// await Task.Delay(5, ct);
|
||||
// color2 = GetPixel(point.X, point.Y);
|
||||
// r2 = color2.R;
|
||||
// g2 = color2.G;
|
||||
// b2 = color2.B;
|
||||
// }
|
||||
//
|
||||
// KeyUp(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private COLORREF GetPixel(int x, int y)
|
||||
{
|
||||
var hdc = User32.GetDC(_hWnd);
|
||||
var c = Gdi32.GetPixel(hdc, x, y);
|
||||
Gdi32.DeleteDC(hdc);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
private void KeyUp(User32.VK key)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(key);
|
||||
@@ -237,16 +94,17 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
Simulation.SendInput.Keyboard.KeyDown(key);
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
}
|
||||
|
||||
public static void LogScreenResolution()
|
||||
private void LogScreenResolution()
|
||||
{
|
||||
AssertUtils.CheckGameResolution("自动音游");
|
||||
|
||||
Logger.LogInformation("{Name}:回到游戏主界面时记得关闭自动音游任务!", "千音雅集");
|
||||
Logger.LogWarning("{Name}:默认的样式“轻漾涟漪”是{No}的!需要手动完成几首曲目获得{Money}千音币后兑换并使用胡桃样式“{Hutao}”!", "千音雅集", "不可用", 600, "疏影引蝶映梅红");
|
||||
var gameScreenSize = SystemControl.GetGameScreenRect(TaskContext.Instance().GameHandle);
|
||||
if (gameScreenSize.Width * 9 != gameScreenSize.Height * 16)
|
||||
{
|
||||
Logger.LogWarning("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏可能无法正常使用自动活动音游功能 !", gameScreenSize.Width, gameScreenSize.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ public class ActionFactory
|
||||
"hydro_collect" => new ElementalCollectHandler(ElementalType.Hydro),
|
||||
"electro_collect" => new ElementalCollectHandler(ElementalType.Electro),
|
||||
"anemo_collect" => new ElementalCollectHandler(ElementalType.Anemo),
|
||||
"pyro_collect" => new ElementalCollectHandler(ElementalType.Pyro),
|
||||
"combat_script" => new CombatScriptHandler(),
|
||||
"mining" => new MiningHandler(),
|
||||
_ => throw new ArgumentException("未知的后置 action 类型")
|
||||
|
||||
@@ -12,54 +12,31 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
internal class AutoFightHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsyncByScript(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
if (!(config != null && config is PathingPartyConfig patyConfig && patyConfig is {AutoFightEnabled:true,JsScriptUseEnabled:true,SoloTaskUseFightEnabled:true} ))
|
||||
{
|
||||
config = null;
|
||||
}
|
||||
await StartFight(ct, config);
|
||||
await StartFight(ct);
|
||||
}
|
||||
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
{
|
||||
await StartFight(ct, config);
|
||||
}
|
||||
|
||||
private async Task StartFight(CancellationToken ct, object? config = null)
|
||||
private async Task StartFight(CancellationToken ct)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("执行 {Text}", "自动战斗");
|
||||
// 爷们要战斗
|
||||
AutoFightParam taskParams = null;
|
||||
if (config != null && config is PathingPartyConfig patyConfig && patyConfig.AutoFightEnabled)
|
||||
var taskParams = new AutoFightParam(GetFightStrategy())
|
||||
{
|
||||
//替换配置为路径追踪
|
||||
|
||||
taskParams = GetFightAutoFightParam(patyConfig.AutoFightConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
taskParams = new AutoFightParam(GetFightStrategy(), TaskContext.Instance().Config.AutoFightConfig);
|
||||
}
|
||||
|
||||
FightFinishDetectEnabled = true,
|
||||
PickDropsAfterFightEnabled = true
|
||||
};
|
||||
var fightSoloTask = new AutoFightTask(taskParams);
|
||||
await fightSoloTask.Start(ct);
|
||||
}
|
||||
|
||||
private AutoFightParam GetFightAutoFightParam(AutoFightConfig? config)
|
||||
private string GetFightStrategy()
|
||||
{
|
||||
AutoFightParam autoFightParam = new AutoFightParam(GetFightStrategy(config), config);
|
||||
return autoFightParam;
|
||||
}
|
||||
|
||||
private string GetFightStrategy(AutoFightConfig config)
|
||||
{
|
||||
var path = Global.Absolute(@"User\AutoFight\" + config.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(config.StrategyName))
|
||||
var path = Global.Absolute(@"User\AutoFight\" + TaskContext.Instance().Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(TaskContext.Instance().Config.AutoFightConfig.StrategyName))
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
throw new Exception("战斗策略文件不存在");
|
||||
@@ -67,9 +44,4 @@ internal class AutoFightHandler : IActionHandler
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private string GetFightStrategy()
|
||||
{
|
||||
return GetFightStrategy(TaskContext.Instance().Config.AutoFightConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
@@ -11,11 +10,11 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public class CombatScriptHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
if (waypointForTrack is { CombatScript: not null })
|
||||
{
|
||||
Logger.LogInformation("执行 {Text}", "简易策略脚本");
|
||||
Logger.LogInformation("执行 {Text}", "战斗策略脚本");
|
||||
var combatScript = waypointForTrack.CombatScript;
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
@@ -41,7 +40,7 @@ public class CombatScriptHandler : IActionHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("策略脚本action_params内容为空");
|
||||
Logger.LogError("战斗脚本action_params内容为空");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
@@ -17,7 +16,7 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
/// </summary>
|
||||
public class ElementalCollectHandler(ElementalType elementalType) : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
@@ -63,7 +62,7 @@ public class ElementalCollectHandler(ElementalType elementalType) : IActionHandl
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("切人失败,无法进行{Element}元素采集", elementalType.ToChinese());
|
||||
Logger.LogError("切人失败,无法进行{Element}元素采集", elementalType.ToString());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -112,26 +111,11 @@ public class ElementalCollectAvatarConfigs
|
||||
new ElementalCollectAvatar("鹿野院平藏", ElementalType.Anemo, true, true),
|
||||
new ElementalCollectAvatar("流浪者", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("闲云", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("蓝砚", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("枫原万叶", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("珐露珊", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("琳妮特", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("温迪", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("琴", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("早柚", ElementalType.Anemo, false, true),
|
||||
// 火
|
||||
new ElementalCollectAvatar("烟绯", ElementalType.Pyro, true, true),
|
||||
new ElementalCollectAvatar("迪卢克", ElementalType.Pyro, false,true),
|
||||
new ElementalCollectAvatar("可莉", ElementalType.Pyro, true, true),
|
||||
new ElementalCollectAvatar("班尼特", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("香菱", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("托马", ElementalType.Pyro,false, true),
|
||||
new ElementalCollectAvatar("胡桃", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("迪希雅", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("夏沃蕾", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("辛焱", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("林尼", ElementalType.Pyro, false, true),
|
||||
new ElementalCollectAvatar("宵宫", ElementalType.Pyro, false, true),
|
||||
];
|
||||
|
||||
public static ElementalCollectAvatar? Get(string name, ElementalType type) => Lists.FirstOrDefault(x => x.Name == name && x.ElementalType == type);
|
||||
|
||||
@@ -6,8 +6,6 @@ using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
@@ -17,10 +15,10 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
[Obsolete]
|
||||
public class ElementalSkillHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
Logger.LogInformation("执行 {Text}", "释放元素战技");
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_E);
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public interface IActionHandler
|
||||
{
|
||||
Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack=null, object? config = null);
|
||||
Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack=null);
|
||||
}
|
||||
@@ -2,11 +2,9 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -24,9 +22,7 @@ public class MiningHandler : IActionHandler
|
||||
坎蒂丝 e(hold)
|
||||
""");
|
||||
|
||||
private readonly ScanPickTask _scanPickTask = new();
|
||||
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
@@ -34,14 +30,14 @@ public class MiningHandler : IActionHandler
|
||||
Logger.LogError("队伍识别未初始化成功!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 挖矿
|
||||
Mining(combatScenes);
|
||||
|
||||
|
||||
await Delay(1000, ct);
|
||||
|
||||
|
||||
// 拾取
|
||||
await _scanPickTask.Start(ct);
|
||||
|
||||
}
|
||||
|
||||
private void Mining(CombatScenes combatScenes)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -19,7 +17,7 @@ public class NahidaCollectHandler : IActionHandler
|
||||
{
|
||||
private DateTime lastETime = DateTime.MinValue;
|
||||
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
Logger.LogInformation("执行 {Nhd} 长按E转圈拾取", "纳西妲");
|
||||
|
||||
@@ -56,7 +54,7 @@ public class NahidaCollectHandler : IActionHandler
|
||||
await Delay(200, ct);
|
||||
|
||||
// 按住E技能 无死角扫码
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_E);
|
||||
await Delay(200, ct);
|
||||
|
||||
// 先地面来一圈
|
||||
@@ -78,7 +76,7 @@ public class NahidaCollectHandler : IActionHandler
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(x, y);
|
||||
await Delay(30, ct);
|
||||
}
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_E);
|
||||
|
||||
lastETime = DateTime.Now;
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
@@ -16,10 +14,10 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
[Obsolete]
|
||||
public class NormalAttackHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
Logger.LogInformation("执行 {Text}", "普通攻击");
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,6 @@ using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
@@ -20,7 +18,7 @@ public class PickAroundHandler() : IActionHandler
|
||||
{
|
||||
private CancellationToken _ct;
|
||||
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
this._ct = ct;
|
||||
Logger.LogInformation("执行 {Text}", "小范围内自动拾取");
|
||||
@@ -48,7 +46,7 @@ public class PickAroundHandler() : IActionHandler
|
||||
|
||||
public async Task MoveCircle(double edgeT, int n)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveLeft, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_A);
|
||||
await Delay(30, _ct);
|
||||
while (n-- > 0)
|
||||
{
|
||||
@@ -56,7 +54,7 @@ public class PickAroundHandler() : IActionHandler
|
||||
await Delay((int)Math.Round(edgeT), _ct);
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveLeft, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_A);
|
||||
await Delay(200, _ct);
|
||||
}
|
||||
|
||||
@@ -68,9 +66,9 @@ public class PickAroundHandler() : IActionHandler
|
||||
await Delay(500, _ct);
|
||||
if (ms > 0)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
await Delay(ms, _ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
await Delay(200, _ct);
|
||||
}
|
||||
}
|
||||
@@ -81,8 +79,8 @@ public class PickAroundHandler() : IActionHandler
|
||||
double y = oldRadius * Math.Sin(angle);
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
await Delay(500, _ct);
|
||||
await MoveAfterTurn(GIActions.MoveBackward.ToActionKey().ToVK(), (int)Math.Round(y) + 200);
|
||||
await MoveAfterTurn(GIActions.MoveLeft.ToActionKey().ToVK(), (int)Math.Round(x));
|
||||
await MoveAfterTurn(User32.VK.VK_S, (int)Math.Round(y) + 200);
|
||||
await MoveAfterTurn(User32.VK.VK_A, (int)Math.Round(x));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
@@ -16,7 +14,7 @@ namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
/// </summary>
|
||||
public class UpDownGrabLeaf : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null, object? config = null)
|
||||
public async Task RunAsync(CancellationToken ct, WaypointForTrack? waypointForTrack = null)
|
||||
{
|
||||
await Delay(500, ct);
|
||||
Logger.LogInformation("开始上下晃动视角抓{Syy}", "四叶印");
|
||||
@@ -26,7 +24,7 @@ public class UpDownGrabLeaf : IActionHandler
|
||||
// kbPress('w'); // 飞行
|
||||
while (i > 0 && !ct.IsCancellationRequested)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.InteractionInSomeMode, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_T);
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
y = -y;
|
||||
|
||||
@@ -2,23 +2,22 @@
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Model.Enum;
|
||||
|
||||
public class ActionEnum(string code, string msg, ActionUseWaypointTypeEnum useWaypointTypeEnum)
|
||||
public class ActionEnum(string code, string msg)
|
||||
{
|
||||
public static readonly ActionEnum StopFlying = new("stop_flying", "下落攻击", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum ForceTp = new("force_tp", "当前点传送", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum NahidaCollect = new("nahida_collect", "纳西妲长按E收集", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum PickAround = new("pick_around", "尝试在周围拾取", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum Fight = new("fight", "战斗", ActionUseWaypointTypeEnum.Path);
|
||||
public static readonly ActionEnum UpDownGrabLeaf = new("up_down_grab_leaf", "四叶印", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum StopFlying = new("stop_flying", "下落攻击");
|
||||
public static readonly ActionEnum ForceTp = new("force_tp", "当前点传送");
|
||||
public static readonly ActionEnum NahidaCollect = new("nahida_collect", "纳西妲长按E收集");
|
||||
public static readonly ActionEnum PickAround = new("pick_around", "尝试在周围拾取");
|
||||
public static readonly ActionEnum Fight = new("fight", "战斗");
|
||||
public static readonly ActionEnum UpDownGrabLeaf = new("up_down_grab_leaf", "四叶印");
|
||||
|
||||
public static readonly ActionEnum HydroCollect = new("hydro_collect", "水元素力采集", ActionUseWaypointTypeEnum.Target);
|
||||
public static readonly ActionEnum ElectroCollect = new("electro_collect", "雷元素力采集", ActionUseWaypointTypeEnum.Target);
|
||||
public static readonly ActionEnum AnemoCollect = new("anemo_collect", "风元素力采集", ActionUseWaypointTypeEnum.Target);
|
||||
|
||||
public static readonly ActionEnum CombatScript = new("combat_script", "战斗策略脚本", ActionUseWaypointTypeEnum.Custom); // 这个必须要 action_params 里面有脚本
|
||||
|
||||
public static readonly ActionEnum Mining = new("mining", "挖矿", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum LogOutput = new("log_output", "输出日志", ActionUseWaypointTypeEnum.Custom);
|
||||
public static readonly ActionEnum HydroCollect = new("hydro_collect", "水元素力采集");
|
||||
public static readonly ActionEnum ElectroCollect = new("electro_collect", "雷元素力采集");
|
||||
public static readonly ActionEnum AnemoCollect = new("anemo_collect", "风元素力采集");
|
||||
|
||||
public static readonly ActionEnum CombatScript = new("combat_script", "战斗策略脚本"); // 这个必须要 action_params 里面有脚本
|
||||
|
||||
public static readonly ActionEnum Mining = new("mining", "挖矿");
|
||||
|
||||
// 还有要加入的其他动作
|
||||
// 滚轮F
|
||||
@@ -29,32 +28,15 @@ public class ActionEnum(string code, string msg, ActionUseWaypointTypeEnum useWa
|
||||
|
||||
public static IEnumerable<ActionEnum> Values
|
||||
{
|
||||
get { yield return StopFlying; }
|
||||
get
|
||||
{
|
||||
yield return StopFlying;
|
||||
}
|
||||
}
|
||||
|
||||
public string Code { get; private set; } = code;
|
||||
public string Msg { get; private set; } = msg;
|
||||
|
||||
public ActionUseWaypointTypeEnum UseWaypointTypeEnum { get; private set; } = useWaypointTypeEnum;
|
||||
|
||||
public static ActionEnum? GetEnumByCode(string? code)
|
||||
{
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var item in Values)
|
||||
{
|
||||
if (item.Code == code)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetMsgByCode(string code)
|
||||
{
|
||||
foreach (var item in Values)
|
||||
@@ -64,14 +46,6 @@ public class ActionEnum(string code, string msg, ActionUseWaypointTypeEnum useWa
|
||||
return item.Msg;
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ActionUseWaypointTypeEnum
|
||||
{
|
||||
Custom, // 跟随路径点 Type
|
||||
Path, // 强制 Path
|
||||
Target // 强制 Target
|
||||
}
|
||||
@@ -6,7 +6,6 @@ public class MoveModeEnum(string code, string msg)
|
||||
{
|
||||
public static readonly MoveModeEnum Walk = new("walk", "步行");
|
||||
public static readonly MoveModeEnum Run = new("run", "奔跑");
|
||||
public static readonly MoveModeEnum Dash = new("dash", "持续冲刺");
|
||||
public static readonly MoveModeEnum Climb = new("climb", "攀爬");
|
||||
public static readonly MoveModeEnum Fly = new("fly", "飞行");
|
||||
public static readonly MoveModeEnum Jump = new("jump", "跳跃");
|
||||
|
||||
@@ -7,7 +7,6 @@ public class WaypointType(string code, string msg)
|
||||
public static readonly WaypointType Path = new("path", "途径点");
|
||||
public static readonly WaypointType Target = new("target", "目标点");
|
||||
public static readonly WaypointType Teleport = new("teleport", "传送点");
|
||||
public static readonly WaypointType Orientation = new("orientation", "方位点");
|
||||
|
||||
public static IEnumerable<WaypointType> Values
|
||||
{
|
||||
@@ -16,7 +15,6 @@ public class WaypointType(string code, string msg)
|
||||
yield return Path;
|
||||
yield return Target;
|
||||
yield return Teleport;
|
||||
yield return Orientation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model.Enum;
|
||||
using System.Diagnostics.Eventing.Reader;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
@@ -23,14 +22,12 @@ public class WaypointForTrack : Waypoint
|
||||
/// 存在 combat_script 的 action 的话,这个值会存在
|
||||
/// </summary>
|
||||
public CombatScript? CombatScript { get; set; }
|
||||
public string? LogInfo { get; set; }
|
||||
|
||||
public WaypointForTrack(Waypoint waypoint)
|
||||
{
|
||||
Type = waypoint.Type;
|
||||
MoveMode = waypoint.MoveMode;
|
||||
Action = waypoint.Action;
|
||||
ActionParams = waypoint.ActionParams;
|
||||
GameX = waypoint.X;
|
||||
GameY = waypoint.Y;
|
||||
// 坐标系转换
|
||||
@@ -42,9 +39,5 @@ public class WaypointForTrack : Waypoint
|
||||
{
|
||||
CombatScript = CombatScriptParser.ParseContext(str, false);
|
||||
}
|
||||
if (waypoint.Action == ActionEnum.LogOutput.Code && waypoint.ActionParams is not null)
|
||||
{
|
||||
LogInfo = waypoint.ActionParams;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,34 +24,20 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Suspend;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static BetterGenshinImpact.GameTask.SystemControl;
|
||||
using ActionEnum = BetterGenshinImpact.GameTask.AutoPathing.Model.Enum.ActionEnum;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
public class PathExecutor
|
||||
public class PathExecutor(CancellationToken ct)
|
||||
{
|
||||
private readonly CameraRotateTask _rotateTask;
|
||||
private readonly TrapEscaper _trapEscaper;
|
||||
private readonly CameraRotateTask _rotateTask = new(ct);
|
||||
private readonly TrapEscaper _trapEscaper = new(ct);
|
||||
private readonly BlessingOfTheWelkinMoonTask _blessingOfTheWelkinMoonTask = new();
|
||||
private AutoSkipTrigger? _autoSkipTrigger;
|
||||
|
||||
private PathingPartyConfig? _partyConfig;
|
||||
private CancellationToken ct;
|
||||
private PathExecutorSuspend pathExecutorSuspend;
|
||||
|
||||
public PathExecutor(CancellationToken ct)
|
||||
{
|
||||
_trapEscaper = new(ct);
|
||||
_rotateTask = new(ct);
|
||||
this.ct = ct;
|
||||
pathExecutorSuspend = new PathExecutorSuspend(this);
|
||||
}
|
||||
|
||||
public PathingPartyConfig PartyConfig
|
||||
{
|
||||
@@ -73,58 +59,8 @@ public class PathExecutor
|
||||
private const int RetryTimes = 2;
|
||||
private int _inTrap = 0;
|
||||
|
||||
|
||||
//记录当前相关点位数组
|
||||
public (int, List<WaypointForTrack>) CurWaypoints { get; set; }
|
||||
|
||||
//记录当前点位
|
||||
public (int, WaypointForTrack) CurWaypoint { get; set; }
|
||||
|
||||
//记录恢复点位数组
|
||||
private (int, List<WaypointForTrack>) RecordWaypoints { get; set; }
|
||||
|
||||
//记录恢复点位
|
||||
private (int, WaypointForTrack) RecordWaypoint { get; set; }
|
||||
|
||||
//跳过除走路径以外的操作
|
||||
private bool _skipOtherOperations = false;
|
||||
|
||||
|
||||
//当到达恢复点位
|
||||
public void TryCloseSkipOtherOperations()
|
||||
{
|
||||
// Logger.LogWarning("判断是否跳过路径追踪:" + (CurWaypoint.Item1 < RecordWaypoint.Item1));
|
||||
if (RecordWaypoints == CurWaypoints && CurWaypoint.Item1 < RecordWaypoint.Item1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_skipOtherOperations)
|
||||
{
|
||||
Logger.LogWarning("已到达上次点位,路径追踪功能恢复");
|
||||
}
|
||||
|
||||
_skipOtherOperations = false;
|
||||
}
|
||||
|
||||
//记录点位,方便后面恢复
|
||||
public void StartSkipOtherOperations()
|
||||
{
|
||||
Logger.LogWarning("记录恢复点位,路径追踪将到达上次点位之前将跳过走路之外的操作");
|
||||
_skipOtherOperations = true;
|
||||
RecordWaypoints = CurWaypoints;
|
||||
RecordWaypoint = CurWaypoint;
|
||||
}
|
||||
|
||||
public async Task Pathing(PathingTask task)
|
||||
{
|
||||
// SuspendableDictionary;
|
||||
const string sdKey = "PathExecutor";
|
||||
var sd = RunnerContext.Instance.SuspendableDictionary;
|
||||
sd.Remove(sdKey);
|
||||
|
||||
RunnerContext.Instance.SuspendableDictionary.TryAdd(sdKey, pathExecutorSuspend);
|
||||
|
||||
if (!task.Positions.Any())
|
||||
{
|
||||
Logger.LogWarning("没有路径点,寻路结束");
|
||||
@@ -145,31 +81,23 @@ public class PathExecutor
|
||||
}
|
||||
|
||||
InitializePathing(task);
|
||||
|
||||
// 转换、按传送点分割路径
|
||||
var waypointsList = ConvertWaypointsForTrack(task.Positions);
|
||||
|
||||
await Delay(100, ct);
|
||||
Navigation.WarmUp(); // 提前加载地图特征点
|
||||
|
||||
foreach (var waypoints in waypointsList) // 按传送点分割的路径
|
||||
foreach (var waypoints in waypointsList)
|
||||
{
|
||||
CurWaypoints = (waypointsList.FindIndex(wps => wps == waypoints), waypoints);
|
||||
|
||||
for (var i = 0; i < RetryTimes; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ResolveAnomalies(); // 异常场景处理
|
||||
foreach (var waypoint in waypoints) // 一条路径
|
||||
foreach (var waypoint in waypoints)
|
||||
{
|
||||
CurWaypoint = (waypoints.FindIndex(wps => wps == waypoint), waypoint);
|
||||
TryCloseSkipOtherOperations();
|
||||
await RecoverWhenLowHp(waypoint); // 低血量恢复
|
||||
if (waypoint.Action == ActionEnum.LogOutput.Code)
|
||||
{
|
||||
Logger.LogInformation(waypoint.LogInfo);
|
||||
}
|
||||
|
||||
if (waypoint.Type == WaypointType.Teleport.Code)
|
||||
{
|
||||
await HandleTeleportWaypoint(waypoint);
|
||||
@@ -179,26 +107,20 @@ public class PathExecutor
|
||||
await BeforeMoveToTarget(waypoint);
|
||||
|
||||
// Path不用走得很近,Target需要接近,但都需要先移动到对应位置
|
||||
if (waypoint.Type == WaypointType.Orientation.Code)
|
||||
{
|
||||
// 方位点,只需要朝向
|
||||
// 考虑到方位点大概率是作为执行action的最后一个点,所以放在此处处理,不和传送点一样单独处理
|
||||
await FaceTo(waypoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
await MoveTo(waypoint);
|
||||
}
|
||||
await MoveTo(waypoint);
|
||||
|
||||
await BeforeMoveCloseToTarget(waypoint);
|
||||
|
||||
if (IsTargetPoint(waypoint))
|
||||
if (waypoint.Type == WaypointType.Target.Code
|
||||
// 除了 fight mining 之外的 action 都需要接近
|
||||
|| (!string.IsNullOrEmpty(waypoint.Action)
|
||||
&& waypoint.Action != ActionEnum.NahidaCollect.Code
|
||||
&& waypoint.Action != ActionEnum.Fight.Code
|
||||
&& waypoint.Action != ActionEnum.CombatScript.Code
|
||||
&& waypoint.Action != ActionEnum.Mining.Code))
|
||||
{
|
||||
await MoveCloseTo(waypoint);
|
||||
}
|
||||
|
||||
//skipOtherOperations如果重试,则跳过相关操作,
|
||||
if ((!string.IsNullOrEmpty(waypoint.Action) && !_skipOtherOperations) || waypoint.Action == ActionEnum.CombatScript.Code)
|
||||
if (!string.IsNullOrEmpty(waypoint.Action))
|
||||
{
|
||||
// 执行 action
|
||||
await AfterMoveToTarget(waypoint);
|
||||
@@ -211,36 +133,10 @@ public class PathExecutor
|
||||
catch (NormalEndException normalEndException)
|
||||
{
|
||||
Logger.LogInformation(normalEndException.Message);
|
||||
if (RunnerContext.Instance.IsContinuousRunGroup)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException e)
|
||||
{
|
||||
if (RunnerContext.Instance.IsContinuousRunGroup)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch (RetryException retryException)
|
||||
{
|
||||
StartSkipOtherOperations();
|
||||
Logger.LogWarning(retryException.Message);
|
||||
}
|
||||
catch (RetryNoCountException retryException)
|
||||
{
|
||||
//特殊情况下,重试不消耗次数
|
||||
i--;
|
||||
StartSkipOtherOperations();
|
||||
Logger.LogWarning(retryException.Message);
|
||||
}
|
||||
finally
|
||||
@@ -253,25 +149,6 @@ public class PathExecutor
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTargetPoint(WaypointForTrack waypoint)
|
||||
{
|
||||
// 方位点不需要接近
|
||||
if (waypoint.Type == WaypointType.Orientation.Code)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var action = ActionEnum.GetEnumByCode(waypoint.Action);
|
||||
if (action is not null && action.UseWaypointTypeEnum != ActionUseWaypointTypeEnum.Custom)
|
||||
{
|
||||
// 强制点位类型的 action,以 action 为准
|
||||
return action.UseWaypointTypeEnum == ActionUseWaypointTypeEnum.Target;
|
||||
}
|
||||
|
||||
// 其余情况和没有action的情况以点位类型为准
|
||||
return waypoint.Type == WaypointType.Target.Code;
|
||||
}
|
||||
|
||||
private async Task<bool> SwitchPartyBefore(PathingTask task)
|
||||
{
|
||||
var ra = CaptureToRectArea();
|
||||
@@ -285,7 +162,7 @@ public class PathExecutor
|
||||
// 血量肯定不满,直接去七天神像回血
|
||||
await TpStatueOfTheSeven();
|
||||
}
|
||||
|
||||
|
||||
var pRaList = ra.FindMulti(AutoFightAssets.Instance.PRa); // 判断是否联机
|
||||
if (pRaList.Count > 0)
|
||||
{
|
||||
@@ -356,7 +233,7 @@ public class PathExecutor
|
||||
if (!string.IsNullOrEmpty(RunnerContext.Instance.PartyName))
|
||||
{
|
||||
// 非空的情况下,先tp到安全位置(回血的七天神像)
|
||||
await new TpTask(ct).TpToStatueOfTheSeven();
|
||||
await new TpTask(ct).Tp(TpTask.ReviveStatueOfTheSevenPointX, TpTask.ReviveStatueOfTheSevenPointY, true);
|
||||
}
|
||||
|
||||
var success = await new SwitchPartyTask().Start(partyName, ct);
|
||||
@@ -487,61 +364,6 @@ public class PathExecutor
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试队伍回血,如果单人回血,由于记录检查时是哪位残血,则当作行走位处理。
|
||||
/// </summary>
|
||||
private async Task<bool> TryPartyHealing()
|
||||
{
|
||||
foreach (var avatar in _combatScenes?.Avatars ?? [])
|
||||
{
|
||||
if (avatar.Name == "白术")
|
||||
{
|
||||
if (avatar.TrySwitch())
|
||||
{
|
||||
//1命白术能两次
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
await Delay(800, ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
await Delay(800, ct);
|
||||
await SwitchAvatar(PartyConfig.MainAvatarIndex);
|
||||
await Delay(4000, ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if (avatar.Name == "希格雯")
|
||||
{
|
||||
if (avatar.TrySwitch())
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
await Delay(11000, ct);
|
||||
await SwitchAvatar(PartyConfig.MainAvatarIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
else if (avatar.Name == "珊瑚宫心海")
|
||||
{
|
||||
if (avatar.TrySwitch())
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
await Delay(500, ct);
|
||||
//尝试Q全队回血
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalBurst);
|
||||
//单人血只给行走位加血
|
||||
await SwitchAvatar(PartyConfig.MainAvatarIndex);
|
||||
await Delay(5000, ct);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task RecoverWhenLowHp(WaypointForTrack waypoint)
|
||||
{
|
||||
if (PartyConfig.OnlyInTeleportRecover && waypoint.Type != WaypointType.Teleport.Code)
|
||||
@@ -550,7 +372,7 @@ public class PathExecutor
|
||||
}
|
||||
|
||||
using var region = CaptureToRectArea();
|
||||
if (Bv.CurrentAvatarIsLowHp(region) && !(await TryPartyHealing() && Bv.CurrentAvatarIsLowHp(region)))
|
||||
if (Bv.CurrentAvatarIsLowHp(region))
|
||||
{
|
||||
Logger.LogInformation("当前角色血量过低,去须弥七天神像恢复");
|
||||
await TpStatueOfTheSeven();
|
||||
@@ -571,7 +393,7 @@ public class PathExecutor
|
||||
{
|
||||
// tp 到七天神像回血
|
||||
var tpTask = new TpTask(ct);
|
||||
await tpTask.TpToStatueOfTheSeven();
|
||||
await tpTask.Tp(TpTask.ReviveStatueOfTheSevenPointX, TpTask.ReviveStatueOfTheSevenPointY, true);
|
||||
await Delay(3000, ct);
|
||||
Logger.LogInformation("HP恢复完成");
|
||||
}
|
||||
@@ -585,16 +407,6 @@ public class PathExecutor
|
||||
await Delay(500, ct); // 多等一会
|
||||
}
|
||||
|
||||
private async Task FaceTo(WaypointForTrack waypoint)
|
||||
{
|
||||
var screen = CaptureToRectArea();
|
||||
var position = await GetPosition(screen);
|
||||
var targetOrientation = Navigation.GetTargetOrientation(waypoint, position);
|
||||
Logger.LogInformation("朝向点,位置({x2},{y2})", $"{waypoint.GameX:F1}", $"{waypoint.GameY:F1}");
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
await Delay(500, ct);
|
||||
}
|
||||
|
||||
private async Task MoveTo(WaypointForTrack waypoint)
|
||||
{
|
||||
// 切人
|
||||
@@ -613,14 +425,15 @@ public class PathExecutor
|
||||
var num = 0;
|
||||
|
||||
// 按下w,一直走
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
num++;
|
||||
if ((DateTime.UtcNow - startTime).TotalSeconds > 240)
|
||||
var now = DateTime.UtcNow;
|
||||
if ((now - startTime).TotalSeconds > 240)
|
||||
{
|
||||
Logger.LogWarning("执行超时,放弃此次追踪");
|
||||
throw new RetryException("路径点执行超时,放弃整条路径");
|
||||
Logger.LogWarning("执行超时,跳过路径点");
|
||||
break;
|
||||
}
|
||||
|
||||
screen = CaptureToRectArea();
|
||||
@@ -638,25 +451,16 @@ public class PathExecutor
|
||||
|
||||
if (distance > 500)
|
||||
{
|
||||
if (pathExecutorSuspend.CheckAndResetSuspendPoint())
|
||||
{
|
||||
throw new RetryNoCountException("可能暂停导致路径过远,重试一次此路线!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogWarning("距离过远,跳过路径点");
|
||||
}
|
||||
|
||||
|
||||
Logger.LogWarning("距离过远,跳过路径点");
|
||||
break;
|
||||
}
|
||||
|
||||
// 非攀爬状态下,检测是否卡死(脱困触发器)
|
||||
if (waypoint.MoveMode != MoveModeEnum.Climb.Code)
|
||||
{
|
||||
if ((DateTime.UtcNow - lastPositionRecord).TotalMilliseconds > 1000)
|
||||
if ((now - lastPositionRecord).TotalMilliseconds > 1000)
|
||||
{
|
||||
lastPositionRecord = DateTime.UtcNow;
|
||||
lastPositionRecord = now;
|
||||
prevPositions.Add(position);
|
||||
if (prevPositions.Count > 8)
|
||||
{
|
||||
@@ -674,7 +478,7 @@ public class PathExecutor
|
||||
//调用脱困代码,由TrapEscaper接管移动
|
||||
await _trapEscaper.RotateAndMove();
|
||||
await _trapEscaper.MoveTo(waypoint);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
Logger.LogInformation("卡死脱离结束");
|
||||
continue;
|
||||
}
|
||||
@@ -694,7 +498,7 @@ public class PathExecutor
|
||||
if (!isFlying)
|
||||
{
|
||||
Debug.WriteLine("未进入飞行状态,按下空格");
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
await Delay(200, ct);
|
||||
}
|
||||
|
||||
@@ -703,7 +507,7 @@ public class PathExecutor
|
||||
|
||||
if (waypoint.MoveMode == MoveModeEnum.Jump.Code)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
await Delay(200, ct);
|
||||
continue;
|
||||
}
|
||||
@@ -711,35 +515,33 @@ public class PathExecutor
|
||||
// 只有设置为run才会一直疾跑
|
||||
if (waypoint.MoveMode == MoveModeEnum.Run.Code)
|
||||
{
|
||||
if (distance > 20 != fastMode) // 距离大于20时可以使用疾跑/自由泳
|
||||
if (distance > 20 != fastMode) // 距离大于30时可以使用疾跑/自由泳
|
||||
{
|
||||
if (fastMode)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyUp);
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyDown);
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
}
|
||||
|
||||
fastMode = !fastMode;
|
||||
}
|
||||
}
|
||||
else if (waypoint.MoveMode == MoveModeEnum.Dash.Code)
|
||||
{
|
||||
if (distance > 20) // 距离大于25时可以使用疾跑
|
||||
{
|
||||
if (Math.Abs((fastModeColdTime - DateTime.UtcNow).TotalMilliseconds) > 1000) //冷却一会
|
||||
{
|
||||
fastModeColdTime = DateTime.UtcNow;
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (waypoint.MoveMode != MoveModeEnum.Climb.Code) //否则自动短疾跑
|
||||
{
|
||||
if (distance > 20)
|
||||
{
|
||||
if (Math.Abs((fastModeColdTime - now).TotalMilliseconds) > 2500) //冷却时间2.5s,回复体力用
|
||||
{
|
||||
fastModeColdTime = now;
|
||||
Simulation.SendInput.Mouse.RightButtonClick();
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 E 技能
|
||||
if (distance > 10 && !string.IsNullOrEmpty(PartyConfig.GuardianAvatarIndex) && double.TryParse(PartyConfig.GuardianElementalSkillSecondInterval, out var s))
|
||||
if (!string.IsNullOrEmpty(PartyConfig.GuardianAvatarIndex) && double.TryParse(PartyConfig.GuardianElementalSkillSecondInterval, out var s))
|
||||
{
|
||||
if (s < 1)
|
||||
{
|
||||
@@ -748,6 +550,7 @@ public class PathExecutor
|
||||
}
|
||||
|
||||
var ms = s * 1000;
|
||||
Debug.WriteLine($"元素战技释放间隔:{(now - _elementalSkillLastUseTime).TotalMilliseconds}ms");
|
||||
if ((DateTime.UtcNow - _elementalSkillLastUseTime).TotalMilliseconds > ms)
|
||||
{
|
||||
// 可能刚切过人在冷却时间内
|
||||
@@ -760,16 +563,6 @@ public class PathExecutor
|
||||
_elementalSkillLastUseTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
// 自动疾跑
|
||||
if (distance > 20 && PartyConfig.AutoRunEnabled)
|
||||
{
|
||||
if (Math.Abs((fastModeColdTime - DateTime.UtcNow).TotalMilliseconds) > 2500) //冷却时间2.5s,回复体力用
|
||||
{
|
||||
fastModeColdTime = DateTime.UtcNow;
|
||||
Simulation.SendInput.SimulateAction(GIActions.SprintMouse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 使用小道具
|
||||
@@ -777,7 +570,7 @@ public class PathExecutor
|
||||
{
|
||||
if ((DateTime.UtcNow - _useGadgetLastUseTime).TotalMilliseconds > PartyConfig.UseGadgetIntervalMs)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuickUseGadget);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_Z);
|
||||
_useGadgetLastUseTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
@@ -786,7 +579,7 @@ public class PathExecutor
|
||||
}
|
||||
|
||||
// 抬起w键
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
|
||||
private async Task UseElementalSkill()
|
||||
@@ -809,39 +602,47 @@ public class PathExecutor
|
||||
// 钟离往身后放柱子
|
||||
if (avatar.Name == "钟离")
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
await Delay(50, ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_S);
|
||||
await Delay(200, ct);
|
||||
}
|
||||
|
||||
if (PartyConfig.GuardianElementalSkillLongPress)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_E);
|
||||
await Task.Delay(800); // 不能取消
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_E);
|
||||
await Delay(700, ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.ElementalSkill);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_E);
|
||||
await Delay(300, ct);
|
||||
}
|
||||
|
||||
// 钟离往身后放柱子 后继续走路
|
||||
if (avatar.Name == "钟离")
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task MoveCloseTo(WaypointForTrack waypoint)
|
||||
{
|
||||
ImageRegion screen;
|
||||
Point2f position;
|
||||
int targetOrientation;
|
||||
var screen = CaptureToRectArea();
|
||||
var position = await GetPosition(screen);
|
||||
var targetOrientation = Navigation.GetTargetOrientation(waypoint, position);
|
||||
Logger.LogInformation("精确接近目标点,位置({x2},{y2})", $"{waypoint.GameX:F1}", $"{waypoint.GameY:F1}");
|
||||
if (waypoint.MoveMode == MoveModeEnum.Fly.Code && waypoint.Action == ActionEnum.StopFlying.Code)
|
||||
{
|
||||
//下落攻击接近目的地
|
||||
Logger.LogInformation("动作:下落攻击");
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
var stepsTaken = 0;
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
@@ -866,30 +667,16 @@ public class PathExecutor
|
||||
targetOrientation = Navigation.GetTargetOrientation(waypoint, position);
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 2);
|
||||
// 小碎步接近
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Thread.Sleep(60);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
// Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(60).KeyUp(User32.VK.VK_W);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(60).KeyUp(User32.VK.VK_W);
|
||||
await Delay(20, ct);
|
||||
}
|
||||
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
|
||||
// 到达目的地后停顿一秒
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
|
||||
private async Task BeforeMoveCloseToTarget(WaypointForTrack waypoint)
|
||||
{
|
||||
if (waypoint.MoveMode == MoveModeEnum.Fly.Code && waypoint.Action == ActionEnum.StopFlying.Code)
|
||||
{
|
||||
//下落攻击接近目的地
|
||||
Logger.LogInformation("动作:下落攻击");
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BeforeMoveToTarget(WaypointForTrack waypoint)
|
||||
{
|
||||
if (waypoint.Action == ActionEnum.UpDownGrabLeaf.Code)
|
||||
@@ -911,8 +698,7 @@ public class PathExecutor
|
||||
|| waypoint.Action == ActionEnum.CombatScript.Code)
|
||||
{
|
||||
var handler = ActionFactory.GetAfterHandler(waypoint.Action);
|
||||
//,PartyConfig
|
||||
await handler.RunAsync(ct, waypoint, PartyConfig);
|
||||
await handler.RunAsync(ct, waypoint);
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -948,10 +734,9 @@ public class PathExecutor
|
||||
|
||||
if (position == new Point2f())
|
||||
{
|
||||
if (!Bv.IsInMainUi(imageRegion))
|
||||
if (!Bv.IsInBigMapUi(imageRegion))
|
||||
{
|
||||
Logger.LogDebug("小地图位置定位失败,且当前不是主界面,进入异常处理");
|
||||
await ResolveAnomalies(imageRegion);
|
||||
await ResolveAnomalies();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -962,23 +747,8 @@ public class PathExecutor
|
||||
* 处理各种异常场景
|
||||
* 需要保证耗时不能太高
|
||||
*/
|
||||
private async Task ResolveAnomalies(ImageRegion? imageRegion = null)
|
||||
private async Task ResolveAnomalies()
|
||||
{
|
||||
if (imageRegion == null)
|
||||
{
|
||||
imageRegion = CaptureToRectArea();
|
||||
}
|
||||
|
||||
// 一些异常界面处理
|
||||
var cookRa = imageRegion.Find(AutoSkipAssets.Instance.CookRo);
|
||||
var closeRa = imageRegion.Find(AutoSkipAssets.Instance.PageCloseMainRo);
|
||||
if (cookRa.IsExist() || closeRa.IsExist())
|
||||
{
|
||||
Logger.LogInformation("检测到其他界面,使用ESC关闭界面");
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);
|
||||
}
|
||||
|
||||
|
||||
// 处理月卡
|
||||
await _blessingOfTheWelkinMoonTask.Start(ct);
|
||||
|
||||
@@ -999,13 +769,7 @@ public class PathExecutor
|
||||
|
||||
if (_autoSkipTrigger == null)
|
||||
{
|
||||
_autoSkipTrigger = new AutoSkipTrigger(new AutoSkipConfig
|
||||
{
|
||||
Enabled = true,
|
||||
QuicklySkipConversationsEnabled = true, // 快速点击过剧情
|
||||
ClosePopupPagedEnabled = true,
|
||||
ClickChatOption = "优先选择最后一个选项",
|
||||
});
|
||||
_autoSkipTrigger = new AutoSkipTrigger();
|
||||
_autoSkipTrigger.Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Suspend;
|
||||
|
||||
public interface ISuspendable
|
||||
{
|
||||
void Suspend(); // 暂停操作
|
||||
void Resume(); // 恢复操作
|
||||
bool IsSuspended { get; } // 是否处于暂停状态
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Suspend;
|
||||
|
||||
//暂停逻辑相关实现,这里主要用来记录,用来恢复相应操作
|
||||
public class PathExecutorSuspend(PathExecutor pathExecutor) : ISuspendable
|
||||
{
|
||||
private bool _isSuspended;
|
||||
|
||||
//记录当前相关点位数组
|
||||
private (int, List<WaypointForTrack>) _waypoints;
|
||||
|
||||
//记录当前点位
|
||||
private (int, WaypointForTrack) _waypoint;
|
||||
|
||||
public bool IsSuspended => _isSuspended;
|
||||
|
||||
public void Suspend()
|
||||
{
|
||||
_waypoints = pathExecutor.CurWaypoints;
|
||||
_waypoint = pathExecutor.CurWaypoint;
|
||||
_isSuspended = true;
|
||||
}
|
||||
|
||||
//路径过远时,检查路径追踪点位经过暂停(当前点位和后一个点位算经过暂停),并重置状态
|
||||
public bool CheckAndResetSuspendPoint()
|
||||
{
|
||||
if (_isSuspended)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pathExecutor.CurWaypoints == _waypoints && (pathExecutor.CurWaypoint == _waypoint || (pathExecutor.CurWaypoint.Item1 - 1) == _waypoint.Item1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
_isSuspended = false;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_waypoints = default;
|
||||
_waypoint = default;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
@@ -41,7 +40,7 @@ public class TrapEscaper(CancellationToken ct)
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 5);
|
||||
|
||||
// 按下w,一直走
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
@@ -71,7 +70,7 @@ public class TrapEscaper(CancellationToken ct)
|
||||
|
||||
//执行旋转
|
||||
await _rotateTask.WaitUntilRotatedTo(targetOrientation, 5);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
//
|
||||
//这里是随机角度的归零逻辑,在脱困执行一秒后将randomAngle设为0以将实际角度重置为正面向点位的角度
|
||||
//其实就是在一段时间内进行角度的修改以实现自动避障
|
||||
@@ -92,12 +91,12 @@ public class TrapEscaper(CancellationToken ct)
|
||||
waypoint.MoveMode != MoveModeEnum.Fly.Code)
|
||||
if (Bv.GetMotionStatus(screen) == MotionStatus.Climb)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_X);
|
||||
Sleep(75);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_S);
|
||||
Sleep(700);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_S);
|
||||
|
||||
LastActionTime = DateTime.UtcNow;
|
||||
|
||||
@@ -118,17 +117,17 @@ public class TrapEscaper(CancellationToken ct)
|
||||
}
|
||||
|
||||
// 抬起w键
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
|
||||
public async Task RotateAndMove()
|
||||
{
|
||||
IncreaseRandomAngle();
|
||||
// 脱离攀爬状态
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_X);
|
||||
await Delay(75, ct);
|
||||
Simulation.SendInput.SimulateAction(GIActions.NormalAttack);
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Delay(500, ct);
|
||||
|
||||
TimeSpan timeSinceLastAction = DateTime.UtcNow - LastActionTime;
|
||||
@@ -167,30 +166,30 @@ public class TrapEscaper(CancellationToken ct)
|
||||
|
||||
private void MoveBackward(int delay)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_S);
|
||||
Sleep(500);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
Sleep(delay);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveBackward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_S);
|
||||
}
|
||||
|
||||
private void MoveLeft(int delay)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveLeft, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_A);
|
||||
Sleep(300);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
Sleep(delay);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveLeft, KeyType.KeyUp);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_A);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_X);
|
||||
}
|
||||
|
||||
private void MoveRight(int delay)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveRight, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_D);
|
||||
Sleep(300);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Jump);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
Sleep(delay);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveRight, KeyType.KeyUp);
|
||||
Simulation.SendInput.SimulateAction(GIActions.Drop);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_D);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_X);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public partial class AutoPickTrigger : ITaskTrigger
|
||||
if (_externalConfig is { ForceInteraction: true })
|
||||
{
|
||||
LogPick(content, "直接拾取");
|
||||
Simulation.SendInput.Keyboard.KeyPress(AutoPickAssets.Instance.PickVk);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_F);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -20,8 +20,7 @@ public class AutoSkipAssets : BaseAssets<AutoSkipAssets>
|
||||
public RecognitionObject ExclamationIconRo;
|
||||
|
||||
public RecognitionObject PageCloseRo;
|
||||
public RecognitionObject CookRo;
|
||||
public RecognitionObject PageCloseMainRo;
|
||||
|
||||
public RecognitionObject CollectRo;
|
||||
public RecognitionObject ReRo;
|
||||
|
||||
@@ -118,24 +117,7 @@ public class AutoSkipAssets : BaseAssets<AutoSkipAssets>
|
||||
RegionOfInterest = new Rect(CaptureRect.Width - CaptureRect.Width / 8, 0, CaptureRect.Width / 8, CaptureRect.Height / 8),
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
CookRo= new RecognitionObject
|
||||
{
|
||||
Name = "Cook",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoSkip", "cook.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width / 15, 0, CaptureRect.Width / 14, CaptureRect.Height /14),
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
PageCloseMainRo= new RecognitionObject
|
||||
{
|
||||
Name = "PageCloseMain",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoSkip", "page_close_main.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width / 25, CaptureRect.Height / 14),
|
||||
DrawOnWindow = true
|
||||
}.InitTemplate();
|
||||
|
||||
|
||||
|
||||
// 一键派遣
|
||||
CollectRo = new RecognitionObject
|
||||
{
|
||||
|
||||
@@ -41,25 +41,25 @@
|
||||
"我带凯亚去没去过的地方玩吧"
|
||||
],
|
||||
"卡维结局1:未来蓝图": [
|
||||
"一起去说服刚刚的委托人吧",
|
||||
"一起去说服委托人吧",
|
||||
"尝试一下新的风格"
|
||||
],
|
||||
"卡维结局2:契约达成": [
|
||||
"一起去说服刚刚的委托人吧",
|
||||
"一起去说服委托人吧",
|
||||
"可以找其他商人筹款"
|
||||
],
|
||||
"卡维结局3:闲时小聚": [
|
||||
"做些别的事转换心情",
|
||||
"做些别的事转化心情",
|
||||
"卡维为什么要当设计师呢",
|
||||
"去找熟人问问"
|
||||
],
|
||||
"卡维结局4:群星之下": [
|
||||
"做些别的事转换心情",
|
||||
"做些别的事转化心情",
|
||||
"卡维为什么要当设计师呢",
|
||||
"还是先别管这个了"
|
||||
],
|
||||
"卡维结局5:第1堂课": [
|
||||
"做些别的事转换心情",
|
||||
"做些别的事转化心情",
|
||||
"找份其他工作赚钱"
|
||||
],
|
||||
"莱依拉结局1:不可说之事": [
|
||||
@@ -74,7 +74,7 @@
|
||||
"莱依拉结局2:代价与回报": [
|
||||
"虽然有些不靠谱",
|
||||
"我陪你去找答案",
|
||||
"仙灵应该不只是想苛责你"
|
||||
"仙灵应该不想苛责你"
|
||||
],
|
||||
"莱依拉结局3:不愿重蹈覆辙": [
|
||||
"虽然有些不靠谱",
|
||||
|
||||
@@ -26,9 +26,9 @@ public partial class AutoSkipConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _quicklySkipConversationsEnabled = true;
|
||||
|
||||
// public int ChatOptionTextWidth { get; set; } = 280;
|
||||
//
|
||||
// public int ExpeditionOptionTextWidth { get; set; } = 130;
|
||||
public int ChatOptionTextWidth { get; set; } = 280;
|
||||
|
||||
public int ExpeditionOptionTextWidth { get; set; } = 130;
|
||||
|
||||
/// <summary>
|
||||
/// 选择选项前的延迟(毫秒)
|
||||
|
||||
@@ -3,7 +3,6 @@ using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip.Assets;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
@@ -66,25 +65,12 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
private List<string> _selectList = [];
|
||||
|
||||
private PostMessageSimulator? _postMessageSimulator;
|
||||
|
||||
private readonly bool _isCustomConfiguration;
|
||||
|
||||
public AutoSkipTrigger()
|
||||
{
|
||||
_autoSkipAssets = AutoSkipAssets.Instance;
|
||||
_config = TaskContext.Instance().Config.AutoSkipConfig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用于内部的其他方法调用
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
public AutoSkipTrigger(AutoSkipConfig config)
|
||||
{
|
||||
_autoSkipAssets = AutoSkipAssets.Instance;
|
||||
_config = config;
|
||||
_isCustomConfiguration = true;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
@@ -93,14 +79,6 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
// IsUseInteractionKey = _config.SelectChatOptionType == SelectChatOptionTypes.UseInteractionKey;
|
||||
_postMessageSimulator = TaskContext.Instance().PostMessageSimulator;
|
||||
|
||||
if (!_isCustomConfiguration)
|
||||
{
|
||||
InitKeyword();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitKeyword()
|
||||
{
|
||||
try
|
||||
{
|
||||
var defaultPauseListJson = Global.ReadAllTextIfExist(@"User\AutoSkip\default_pause_options.json");
|
||||
@@ -204,7 +182,7 @@ public partial class AutoSkipTrigger : ITaskTrigger
|
||||
{
|
||||
if (IsUseInteractionKey)
|
||||
{
|
||||
_postMessageSimulator? .SimulateActionBackground(GIActions.PickUpOrInteract); // 注意这里不是交互键 NOTE By Ayu0K: 这里确实是交互键
|
||||
_postMessageSimulator?.KeyPressBackground(User32.VK.VK_F); // 注意这里不是交互键
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
@@ -63,11 +62,13 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogInformation("自动追踪中断:" + e.Message);
|
||||
// NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Cancelled().Build());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
// NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Failure().Build());
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -112,7 +113,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
{
|
||||
// 距离大于150米,先传送到最近的传送点
|
||||
// J 打开任务 切换追踪打开地图 中心点就是任务点
|
||||
Simulation.SendInput.SimulateAction(GIActions.OpenQuestMenu);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_J);
|
||||
Sleep(800, _ct);
|
||||
// TODO 识别是否在任务界面
|
||||
// 切换追踪
|
||||
@@ -178,7 +179,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
private void StartTrackPoint()
|
||||
{
|
||||
// V键直接追踪
|
||||
Simulation.SendInput.SimulateAction(GIActions.QuestNavigation);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_V);
|
||||
Sleep(3000, _ct);
|
||||
|
||||
var ra = CaptureToRectArea();
|
||||
@@ -215,7 +216,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(-50, 0);
|
||||
if (wDown)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
wDown = false;
|
||||
}
|
||||
Debug.WriteLine("使追踪点位于俯视角上方");
|
||||
@@ -241,7 +242,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
{
|
||||
if (!wDown)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
wDown = true;
|
||||
}
|
||||
}
|
||||
@@ -250,7 +251,7 @@ public class AutoTrackTask(AutoTrackParam param) : BaseIndependentTask
|
||||
{
|
||||
if (wDown)
|
||||
{
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
wDown = false;
|
||||
}
|
||||
// 识别距离
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Core.Simulator.Extensions;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
@@ -320,10 +319,7 @@ public class AutoTrackPathTask
|
||||
var angle1 = GetCharacterOrientationAngle();
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(CharMovingUnit, 0);
|
||||
Sleep(500);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyDown);
|
||||
Sleep(100);
|
||||
Simulation.SendInput.SimulateAction(GIActions.MoveForward, KeyType.KeyUp);
|
||||
// Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(100).KeyUp(User32.VK.VK_W);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W).Sleep(100).KeyUp(User32.VK.VK_W);
|
||||
Sleep(1000);
|
||||
var angle2 = GetCharacterOrientationAngle();
|
||||
var angleOffset = angle2 - angle1;
|
||||
|
||||
@@ -15,7 +15,6 @@ public class GiWorldPosition
|
||||
/// 坐标描述
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
public string? Country { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 坐标 x,y,z 三个值,分别代表纵向、高度、横向,采用原神实际的坐标系
|
||||
|
||||