8000 Display ballast ratio in sub editor by MatthiasKunnen · Pull Request #15714 · FakeFishGames/Barotrauma · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@MatthiasKunnen
Copy link
@MatthiasKunnen MatthiasKunnen commented Mar 10, 2025

The ballast ratio is the total hull volume divided by the volume of hulls containing the word "ballast". This is the same approach as the "Wet room" detection.
The purpose is ease-of-use when building submarines and trying to figure out ballast tank sizes.

Current workflow:

  1. Change hull size.
  2. Select all ballast tanks manually, this can be especially painful if a lot of linked hulls are present and the ballast tanks are scattered around the sub.
  3. Divide total volume by selected volume using an external calculator. Now you know if the ballast-to-total volume has changed as you intended.
  4. Tinker with hull size again, repeat these steps.

New workflow

  1. Change hull size.
  2. Instantly see the current ballast ratio.
  3. Happily fiddle with hull size enjoying immediate feedback.

image

Note

I'm currently reusing the ballast translation from the roomname which is usually an i18n no-no. Since translations are not part of this repo, this will have to be addressed upstream.

Potential future PR

I would like to propose making the optimal neutral ballast level calculation automatic too in another PR. It might look like this:

Total hull volume:
7024156

Ballast:
1351447 (19.24 % of total volume)
optimal neutral ballast level is 0.3638

Selected volume:
512345 (7.29 % of total volume)
optimal neutral ballast level is 0.9597

Any thoughts?

The ballast ratio is the total hull volume divided by the ballast volume.
});

string retVal = $"{TextManager.Get("TotalHullVolume")}:\n{totalVolume}";
retVal += $" ({(ballastVolume / totalVolume * 100).ToString("0.00")} % {TextManager.Get("roomname.Ballast")})";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that if totalVolume is 0.0f, the division here could result in Infinity, which might cause unexpected behavior when formatting the string.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought when writing this, though GetTotalHullVolume is only called when at least one hull is selected so this should never happen.
That being said, I have no problem adding a defensive guard just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0