Better brake lights

This commit is contained in:
EntenKoeniq
2022-01-01 17:24:55 +01:00
parent 42903a1b53
commit 6f2da854a9
7 changed files with 47 additions and 31 deletions

View File

@ -362,26 +362,32 @@ namespace CoopClient.Entities.Player
UpdateOnFootPosition();
}
private byte LastStuckCount = 0;
private bool StuckDetection = false;
private ulong LastStuckTime;
private void UpdateOnFootPosition(bool updatePosition = true, bool updateRotation = true, bool updateVelocity = true)
{
if (Character.Position.DistanceTo(Position) > 5f)
ulong time = Util.GetTickCount64();
if (StuckDetection)
{
if (Util.GetTickCount64() - LastStuckTime < 1000)
if (time - LastStuckTime >= 500)
{
LastStuckCount = 0;
StuckDetection = false;
if (Character.Position.DistanceTo(Position) > 5f)
{
Character.PositionNoOffset = Position;
Character.Rotation = Rotation;
}
}
++LastStuckCount;
if (LastStuckCount >= 5)
}
else if (time - LastStuckTime >= 500)
{
if (Character.Position.DistanceTo(Position) > 5f)
{
Character.Position = Position;
LastStuckCount = 0;
StuckDetection = true;
LastStuckTime = time;
}
LastStuckTime = Util.GetTickCount64();
}
if (updatePosition)