From b375cd3be1ff0562d2b422f7c9ad1656769e40f4 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 29 Mar 2019 17:24:31 +0200 Subject: [PATCH] (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) --- Barotrauma/BarotraumaShared/Source/Map/Hull.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs index da308afe7..b9b71de7e 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Hull.cs @@ -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; } }