Skip to content

Commit 8cc5ce7

Browse files
committed
修复自动开门没事就启动的问题
1 parent f87bbef commit 8cc5ce7

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

BetterGenshinImpact/GameTask/GameLoading/GameLoading.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ namespace BetterGenshinImpact.GameTask.GameLoading;
1919

2020
public class GameLoadingTrigger : ITaskTrigger
2121
{
22+
public static bool GlobalEnabled = true;
23+
2224
public string Name => "自动开门";
2325

24-
public bool IsEnabled { get; set; }
26+
public bool IsEnabled { get => GlobalEnabled; set {} }
2527

2628
public int Priority => 999;
2729

@@ -61,9 +63,17 @@ public GameLoadingTrigger()
6163
_assets = GameLoadingAssets.Instance;
6264
}
6365

66+
public void InnerSetEnabled(bool enabled)
67+
{
68+
GlobalEnabled = enabled;
69+
}
70+
6471
public void Init()
6572
{
66-
IsEnabled = _config.AutoEnterGameEnabled;
73+
if (!_config.AutoEnterGameEnabled)
74+
{
75+
InnerSetEnabled(false);
76+
}
6777

6878
// // 前面没有联动启动原神,这个任务也不用启动
6979
// if ((DateTime.Now - TaskContext.Instance().LinkedStartGenshinTime).TotalMinutes >= 5)
@@ -234,14 +244,14 @@ public void OnCapture(CaptureContent content)
234244
// 5min 后自动停止
235245
if ((DateTime.Now - _triggerStartTime).TotalMinutes >= 5)
236246
{
237-
IsEnabled = false;
247+
InnerSetEnabled(false);
238248
return;
239249
}
240250
// 成功进入游戏判断
241251
if (Bv.IsInMainUi(content.CaptureRectArea) || Bv.IsInAnyClosableUi(content.CaptureRectArea) || Bv.IsInDomain(content.CaptureRectArea))
242252
{
243-
_logger.LogInformation("已进入游戏");
244-
IsEnabled = false;
253+
_logger.LogInformation("当前在游戏主界面");
254+
InnerSetEnabled(false);
245255
return;
246256
}
247257

BetterGenshinImpact/Service/ScriptService.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,6 @@ await Task.Run(async () =>
605605
SystemControl.ActivateWindow();
606606
}
607607

608-
//自启动游戏,如果鼠标在游戏外面,将无法自动开门,这里尝试移动到游戏界面
609-
if (sw.Elapsed.TotalSeconds < 200)
610-
{
611-
GlobalMethod.MoveMouseTo(300, 300);
612-
}
613-
614-
615608
}
616609
}
617610
});

0 commit comments

Comments
 (0)