(db658d442) Keep oxygen percentage at the same level when resizing hulls in the sub editor (otherwise scaling up a hull will cause it to have less oxygen and vice versa)

This commit is contained in:
Joonas Rikkonen
2019-03-29 17:24:31 +02:00
parent ddfd7274e9
commit b375cd3be1

View File

@@ -79,6 +79,7 @@ namespace Barotrauma
}
set
{
float prevOxygenPercentage = OxygenPercentage;
base.Rect = value;
if (Submarine == null || !Submarine.Loading)
@@ -87,6 +88,7 @@ namespace Barotrauma
Gap.UpdateHulls();
}
OxygenPercentage = prevOxygenPercentage;
surface = drawSurface = rect.Y - rect.Height + WaterVolume / rect.Width;
Pressure = surface;
}
@@ -162,7 +164,7 @@ namespace Barotrauma
public float OxygenPercentage
{
get { return oxygen / Volume * 100.0f; }
get { return Volume <= 0.0f ? 100.0f : oxygen / Volume * 100.0f; }
set { Oxygen = (value / 100.0f) * Volume; }
}