log error when trying to set invalid solution ratio and clamp it (#13675)

This commit is contained in:
Rane
2023-01-23 19:33:11 -05:00
committed by GitHub
parent bda3a1047f
commit fb3df96654

View File

@@ -18,6 +18,15 @@ public sealed class SolutionContainerVisualsSystem : VisualizerSystem<SolutionCo
if (!args.Sprite.LayerMapTryGet(component.Layer, out var fillLayer))
return;
// Currently some solution methods such as overflowing will try to update appearance with a
// volume greater than the max volume. We'll clamp it so players don't see
// a giant error sign and error for debug.
if (fraction > 1f)
{
Logger.Error("Attempted to set solution container visuals volume ratio on " + ToPrettyString(uid) + " to a value greater than 1. Volume should never be greater than max volume!");
fraction = 1f;
}
var closestFillSprite = (int) Math.Round(fraction * component.MaxFillLevels);
if (closestFillSprite > 0)