Fix desktop hands, added run

This commit is contained in:
glax 2023-11-30 19:58:01 +01:00
parent 595c8bf202
commit 5c9d159ccc

View File

@ -35,7 +35,7 @@ public class OSCCollar
private DateTime _lastNilMessageSent = DateTime.UnixEpoch; private DateTime _lastNilMessageSent = DateTime.UnixEpoch;
private DateTime _lastConsoleOutput = DateTime.UnixEpoch; private DateTime _lastConsoleOutput = DateTime.UnixEpoch;
private static readonly TimeSpan ConsoleUpdateInterval = TimeSpan.FromMilliseconds(100); private static readonly TimeSpan ConsoleUpdateInterval = TimeSpan.FromMilliseconds(100);
private static readonly TimeSpan UpdateInterval = TimeSpan.FromMilliseconds(1); private static readonly TimeSpan UpdateInterval = TimeSpan.FromMilliseconds(10);
private static readonly TimeSpan MessageMinInterval = TimeSpan.FromMilliseconds(400); private static readonly TimeSpan MessageMinInterval = TimeSpan.FromMilliseconds(400);
private readonly double _radius; private readonly double _radius;
private GPS GPS1 { get; init; } private GPS GPS1 { get; init; }
@ -185,19 +185,21 @@ public class OSCCollar
{ {
this.Client.Send("/input/Vertical", 0f); this.Client.Send("/input/Vertical", 0f);
this.Client.Send("/input/Horizontal", 0f); this.Client.Send("/input/Horizontal", 0f);
this.Client.Send("/input/Run", 0);
this._lastNilMessageSent = DateTime.Now; this._lastNilMessageSent = DateTime.Now;
_nilSent++; _nilSent++;
} }else if (_allowMoving)
if (_allowMoving)
{ {
Thread.Sleep(1);
if (_leashStretch > 0.1) if (_leashStretch > 0.1)
{ {
this.Client.Send("/input/Vertical", Convert.ToSingle(_verticalMovement)); this.Client.Send("/input/Vertical", Convert.ToSingle(_verticalMovement));
this.Client.Send("/input/Horizontal", Convert.ToSingle(_horizontalMovement)); this.Client.Send("/input/Horizontal", Convert.ToSingle(_horizontalMovement));
this._lastNilMessageSent = DateTime.Now;
} }
if (_leashStretch > 0.4)
this.Client.Send("/input/Run", 1);
else
this.Client.Send("/input/Run", 0);
} }
if (_lastConsoleOutput.Add(ConsoleUpdateInterval) < DateTime.Now) if (_lastConsoleOutput.Add(ConsoleUpdateInterval) < DateTime.Now)