Fixed engines trying to apply infinite force to the submarine if MinVoltage is set to zero.
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public float CurrentVolume
|
public float CurrentVolume
|
||||||
{
|
{
|
||||||
get { return Math.Abs((force / 100.0f) * (voltage / minVoltage)); }
|
get { return Math.Abs((force / 100.0f) * Math.Min(voltage / minVoltage, 1.0f)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
@@ -70,7 +70,7 @@ namespace Barotrauma.Items.Components
|
|||||||
Force = MathHelper.Lerp(force, (voltage < minVoltage) ? 0.0f : targetForce, 0.1f);
|
Force = MathHelper.Lerp(force, (voltage < minVoltage) ? 0.0f : targetForce, 0.1f);
|
||||||
if (Math.Abs(Force) > 1.0f)
|
if (Math.Abs(Force) > 1.0f)
|
||||||
{
|
{
|
||||||
Vector2 currForce = new Vector2((force / 100.0f) * maxForce * (voltage / minVoltage), 0.0f);
|
Vector2 currForce = new Vector2((force / 100.0f) * maxForce * Math.Min(voltage / minVoltage, 1.0f), 0.0f);
|
||||||
|
|
||||||
item.Submarine.ApplyForce(currForce);
|
item.Submarine.ApplyForce(currForce);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user