39 lines
613 B
C#
39 lines
613 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()
|
|
{
|
|
if ( !UseABS )
|
|
return;
|
|
|
|
ABSActive = false;
|
|
|
|
if ( TotalSpeed < 100 || ABSActive )
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|