Fixed engines trying to apply infinite force to the submarine if MinVoltage is set to zero.

This commit is contained in:
Joonas Rikkonen
2018-08-07 14:36:08 +03:00
parent 004250409a
commit 4aeaf93af8

View File

@@ -56,7 +56,7 @@ namespace Barotrauma.Items.Components
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)
@@ -70,7 +70,7 @@ namespace Barotrauma.Items.Components
Force = MathHelper.Lerp(force, (voltage < minVoltage) ? 0.0f : targetForce, 0.1f);
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);