From 4aeaf93af85d0b9bd222dcd9d07bd2075e0b2467 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 7 Aug 2018 14:36:08 +0300 Subject: [PATCH] Fixed engines trying to apply infinite force to the submarine if MinVoltage is set to zero. --- .../Source/Items/Components/Machines/Engine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Engine.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Engine.cs index f58aa9494..a62722935 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Engine.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Machines/Engine.cs @@ -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);