diff --git a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.Capabilities.cs b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.Capabilities.cs index a40f0f2560..13d11b13f2 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.Capabilities.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.Capabilities.cs @@ -113,6 +113,14 @@ public sealed partial class SolutionContainerSystem : solution.CurrentVolume; } + public float PercentFull(EntityUid uid) + { + if (!TryGetDrainableSolution(uid, out var solution) || solution.MaxVolume.Equals(FixedPoint2.Zero)) + return 0; + + return ((solution.CurrentVolume.Float() / solution.MaxVolume.Float()) * 100); + } + public bool TryGetFitsInDispenser(EntityUid owner, [NotNullWhen(true)] out Solution? solution, FitsInDispenserComponent? dispenserFits = null, diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index a56094a5d6..f3fb9b790b 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -74,6 +74,35 @@ namespace Content.Server.Nutrition.EntitySystems var openedText = Loc.GetString(IsEmpty(uid, component) ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened"); args.Message.AddMarkup($"\n{Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))}"); + if (!IsEmpty(uid, component)) + { + if (TryComp(component.Owner, out var comp)) + { + //provide exact measurement for beakers + args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", _solutionContainerSystem.DrainAvailable(uid)))}"); + } + else + { + //general approximation + string remainingString; + switch ((int)_solutionContainerSystem.PercentFull(uid)) + { + case int perc when perc == 100: + remainingString = "drink-component-on-examine-is-full"; + break; + case int perc when perc > 66: + remainingString = "drink-component-on-examine-is-mostly-full"; + break; + case int perc when perc > 33: + remainingString = HalfEmptyOrHalfFull(args); + break; + default: + remainingString = "drink-component-on-examine-is-mostly-empty"; + break; + } + args.Message.AddMarkup($" - {Loc.GetString(remainingString)}"); + } + } } private void SetOpen(EntityUid uid, bool opened = false, DrinkComponent? component = null) @@ -353,5 +382,17 @@ namespace Content.Server.Nutrition.EntitySystems ev.Verbs.Add(verb); } + + // some see half empty, and others see half full + private string HalfEmptyOrHalfFull(ExaminedEvent args) + { + string remainingString = "drink-component-on-examine-is-half-full"; + + if (TryComp(args.Examiner, out var examiner) && examiner.EntityName.Length > 0 + && string.Compare(examiner.EntityName.Substring(0, 1), "m", StringComparison.InvariantCultureIgnoreCase) > 0) + remainingString = "drink-component-on-examine-is-half-empty"; + + return remainingString; + } } } diff --git a/Resources/Locale/en-US/nutrition/components/drink-component.ftl b/Resources/Locale/en-US/nutrition/components/drink-component.ftl index 5cc8f4e5e5..9a1b1b3f78 100644 --- a/Resources/Locale/en-US/nutrition/components/drink-component.ftl +++ b/Resources/Locale/en-US/nutrition/components/drink-component.ftl @@ -2,6 +2,12 @@ drink-component-on-use-is-empty = {$owner} is empty! drink-component-on-examine-is-empty = Empty drink-component-on-examine-is-opened = Opened drink-component-on-examine-details-text = [color={$colorName}]{$text}[/color] +drink-component-on-examine-is-full = Full +drink-component-on-examine-is-mostly-full = Mostly Full +drink-component-on-examine-is-half-full = Halfway Full +drink-component-on-examine-is-half-empty = Halfway Empty +drink-component-on-examine-is-mostly-empty = Mostly Empty +drink-component-on-examine-exact-volume = {$amount}u Full drink-component-try-use-drink-not-open = Open {$owner} first! drink-component-try-use-drink-is-empty = {$entity} is empty! drink-component-try-use-drink-cannot-drink = You can't drink anything!