super powerful engine
This commit is contained in:
@@ -13,20 +13,24 @@
|
||||
// Physical properties
|
||||
public float MomentOfInertia { get; set; } = 0.25f;
|
||||
public float IdleRPM { get; set; } = 800f;
|
||||
public float RevLimit { get; set; } = 12000;
|
||||
public float StallSpeed { get; set; } = 200f;
|
||||
public float Throttle { get; set; } = 0f;
|
||||
public bool IsRunning => RPM > StallSpeed;
|
||||
private float _cutoffUntil = 0;
|
||||
private bool _cutoff = false;
|
||||
|
||||
// Torque curve
|
||||
public Dictionary<float, float> TorqueCurve { get; set; } = new()
|
||||
{
|
||||
{ 0f, 0f },
|
||||
{ 800f, 150f },
|
||||
{ 2000f, 250 },
|
||||
{ 4500f, 250f },
|
||||
{ 6800f, 200f },
|
||||
{ 7200f, 150 },
|
||||
{ 7500f, 0f },
|
||||
{ 800f, 200f },
|
||||
{ 2000f, 300 },
|
||||
{ 4500f, 300f },
|
||||
{ 6800f, 300 },
|
||||
{ 7200f, 350 },
|
||||
{ 11000f, 600f },
|
||||
{ 12500, 500f },
|
||||
};
|
||||
|
||||
public Engine()
|
||||
@@ -34,6 +38,16 @@
|
||||
FlywheelEnergy = GetEnergyFromRPM(IdleRPM);
|
||||
}
|
||||
|
||||
public void UpdateRevLimiter(float totalTime)
|
||||
{
|
||||
if (RPM > RevLimit)
|
||||
{
|
||||
_cutoffUntil = totalTime + 0.01f;
|
||||
}
|
||||
|
||||
_cutoff = (totalTime < _cutoffUntil);
|
||||
}
|
||||
|
||||
public float CalculateFrictionLoss(float deltaTime)
|
||||
{
|
||||
float frictionTorque;
|
||||
@@ -55,7 +69,9 @@
|
||||
|
||||
public float CalculateCombustionPower(float deltaTime)
|
||||
{
|
||||
float torque = GetTorqueOutput() * GetActualThrottle();
|
||||
float throttle = GetActualThrottle();
|
||||
if (_cutoff) throttle = 0;
|
||||
float torque = GetTorqueOutput() * throttle;
|
||||
return torque * AngularVelocity * deltaTime;
|
||||
}
|
||||
|
||||
@@ -109,8 +125,9 @@
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
public void Update(float deltaTime, float totalTime)
|
||||
{
|
||||
UpdateRevLimiter(totalTime);
|
||||
// Combustion adds energy (if throttle > 0)
|
||||
float combustionEnergy = CalculateCombustionPower(deltaTime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user