From 864520442bc1ccfa4b799ebfbe347e949ddaebff Mon Sep 17 00:00:00 2001 From: Matthias Kunnen Date: Mon, 10 Mar 2025 14:30:12 +0000 Subject: [PATCH] Display ballast ratio in sub editor The ballast ratio is the total hull volume divided by the ballast volume. --- .../ClientSource/Screens/SubEditorScreen.cs | 17 ++++++++++++++++- .../BarotraumaShared/SharedSource/Map/Hull.cs | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs index 60d3eff907..44a2e3d2cb 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs @@ -230,7 +230,22 @@ private static string GetSubDescription() private static LocalizedString GetTotalHullVolume() { - return $"{TextManager.Get("TotalHullVolume")}:\n{Hull.HullList.Sum(h => h.Volume)}"; + float totalVolume = 0.0f; + float ballastVolume = 0.0f; + Hull.HullList.ForEach(h => + { + totalVolume += h.Volume; + + if (h.IsBallast()) + { + ballastVolume += h.Volume; + } + }); + + string retVal = $"{TextManager.Get("TotalHullVolume")}:\n{totalVolume}"; + retVal += $" ({(ballastVolume / totalVolume * 100).ToString("0.00")} % {TextManager.Get("roomname.Ballast")})"; + + return retVal; } private static LocalizedString GetSelectedHullVolume() diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs index 4e87e96d9c..8312bb093a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Hull.cs @@ -1407,6 +1407,11 @@ private void DetermineIsAirlock() IsAirlock = false; } + public bool IsBallast() + { + return roomName != null && roomName.Contains("ballast", StringComparison.OrdinalIgnoreCase); + } + /// /// Does this hull have any doors leading outside? ///