velox/Code/Car/VeloXCar.ABS.cs
2025-11-25 19:16:40 +07:00

38 lines
606 B
C#

using Sandbox;
using System;
namespace VeloX;
public partial class VeloXCar
{
public bool ABSActive { get; private set; } = true;
public static bool UseABS = true;
private void UpdateABS()
{
ABSActive = false;
if ( !UseABS )
return;
if ( TotalSpeed < 100 || Steering.AlmostEqual( 0, 1 ) )
return;
if ( Brakes == 0 || CarDirection != 1 || Engine.RevLimiterActive || Handbrake >= 0.1f )
return;
foreach ( var wheel in Wheels )
{
if ( !wheel.IsOnGround )
continue;
if ( wheel.wheelIsBlocked )
{
ABSActive = true;
wheel.BrakeTorque = 0f;
}
}
}
}