30 lines
745 B
C#
30 lines
745 B
C#
using Car_simulation.Core.Physics;
|
|
|
|
namespace Car_simulation.Core.Components
|
|
{
|
|
public class BrakeSystem : ICarComponent
|
|
{
|
|
public float BrakeInput { get; set; } = 0f;
|
|
public float MaxBrakeTorque { get; set; } = 3000f;
|
|
|
|
private WheelSystem _wheelSystem;
|
|
|
|
public BrakeSystem(WheelSystem wheelSystem)
|
|
{
|
|
_wheelSystem = wheelSystem;
|
|
}
|
|
|
|
public void Update(float deltaTime)
|
|
{
|
|
if (BrakeInput <= 0) return;
|
|
|
|
float brakeTorque = BrakeInput * MaxBrakeTorque;
|
|
_wheelSystem.ApplyTorque(-brakeTorque, deltaTime);
|
|
}
|
|
|
|
public float GetBrakeTorque()
|
|
{
|
|
return BrakeInput * MaxBrakeTorque;
|
|
}
|
|
}
|
|
} |