velox/Code/Car/VeloXCar.ABS.cs
2025-11-20 20:01:57 +07:00

38 lines
644 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 || ABSActive || 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.NormalizedLongitudinalSlip >= 0.55f )
{
ABSActive = true;
wheel.BrakeTorque *= 0.25f;
}
}
}
}