This commit is contained in:
Boki 2026-02-28 15:13:22 -05:00
parent bef61f841d
commit c3de5fdb63
107 changed files with 0 additions and 0 deletions

View file

@ -1,40 +0,0 @@
namespace Poe2Trade.Navigation;
/// <summary>
/// Detects when the player hasn't moved significantly over a window of frames.
/// </summary>
internal class StuckDetector
{
private readonly double _threshold;
private readonly int _frameCount;
private int _counter;
private MapPosition? _lastPosition;
public bool IsStuck => _counter >= _frameCount;
public StuckDetector(double threshold, int frameCount)
{
_threshold = threshold;
_frameCount = frameCount;
}
public void Update(MapPosition position)
{
if (_lastPosition != null)
{
var dx = position.X - _lastPosition.X;
var dy = position.Y - _lastPosition.Y;
if (Math.Sqrt(dx * dx + dy * dy) < _threshold)
_counter++;
else
_counter = 0;
}
_lastPosition = position;
}
public void Reset()
{
_counter = 0;
_lastPosition = null;
}
}