initial BFS movement

This commit is contained in:
Boki 2026-02-13 16:56:44 -05:00
parent 25257e1517
commit 490fb8bdba
7 changed files with 258 additions and 101 deletions

View file

@ -34,7 +34,7 @@ public partial class MainWindowViewModel : ObservableObject
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
private const int VK_F12 = 0x7B;
private const int VK_END = 0x23;
[ObservableProperty]
private string _state = "Idle";
@ -130,7 +130,10 @@ public partial class MainWindowViewModel : ObservableObject
{
try
{
await _bot.Start([]);
if (_bot.Mode == BotMode.Mapping)
await _bot.StartMapping();
else
await _bot.Start([]);
IsStarted = true;
}
catch (Exception ex)
@ -186,10 +189,10 @@ public partial class MainWindowViewModel : ObservableObject
try
{
// F12 hotkey — edge-detect (trigger once per press)
var f12Down = (GetAsyncKeyState(VK_F12) & 0x8000) != 0;
if (f12Down && !f12WasDown)
var endDown = (GetAsyncKeyState(VK_END) & 0x8000) != 0;
if (endDown && !f12WasDown)
{
Log.Information("F12 pressed — emergency stop");
Log.Information("END pressed — emergency stop");
await _bot.Navigation.Stop();
_bot.Pause();
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
@ -198,10 +201,12 @@ public partial class MainWindowViewModel : ObservableObject
State = "Stopped (F12)";
});
}
f12WasDown = f12Down;
f12WasDown = endDown;
// Minimap capture + display
var bytes = _bot.Navigation.ProcessFrame(SelectedMinimapStage);
// Minimap display: if explore loop owns capture, just render viewport
var bytes = _bot.Navigation.IsExploring
? _bot.Navigation.GetViewportSnapshot()
: _bot.Navigation.ProcessFrame(SelectedMinimapStage);
if (bytes != null)
{
var bmp = new Bitmap(new MemoryStream(bytes));