]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Puddle fixes (#15820)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 26 Apr 2023 11:29:31 +0000 (21:29 +1000)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2023 11:29:31 +0000 (21:29 +1000)
Content.Client/Fluids/PuddleSystem.cs
Content.Server/Fluids/EntitySystems/PuddleSystem.cs
Content.Shared/Fluids/SharedPuddleSystem.cs

index 12004d7ff68a76eb39abb1b9fca0a28c36c8c31b..54b1d5b86b931a51b111690a7edd7c0ef9bfb8c4 100644 (file)
@@ -36,7 +36,7 @@ public sealed class PuddleSystem : SharedPuddleSystem
                 args.Sprite.LayerSetState(0, $"{smooth.StateBase}a");
                 _smooth.SetEnabled(uid, false, smooth);
             }
-            else if (volume < 0.6f)
+            else if (volume < MediumThreshold)
             {
                 args.Sprite.LayerSetState(0, $"{smooth.StateBase}b");
                 _smooth.SetEnabled(uid, false, smooth);
index 902f2188e296140633d0681fae3d837b596c6c23..3552c8d8971af71d50ea4642ec4a86deadc40860 100644 (file)
@@ -105,7 +105,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
                     continue;
                 }
 
-                var remaining = neighborSolution.Volume - puddle.OverflowVolume;
+                var remaining = puddle.OverflowVolume - neighborSolution.Volume;
 
                 if (remaining <= FixedPoint2.Zero)
                     continue;
@@ -129,20 +129,13 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
             }
         }
 
-        // Then we go to free tiles -> only overflow if we can go up to capacity at least.
+        // Then we go to free tiles.
+        // Need to go even if we have a little remainder to avoid solution sploshing around internally
+        // for ages.
         if (args.NeighborFreeTiles.Count > 0 && args.Updates > 0)
         {
-            // We'll only spill if we have the minimum threshold per tile.
-            var spillCount = (int) Math.Floor(overflow.Volume.Float() / component.OverflowVolume.Float());
-
-            if (spillCount == 0)
-            {
-                return;
-            }
-
             _random.Shuffle(args.NeighborFreeTiles);
-            spillCount = Math.Min(args.NeighborFreeTiles.Count, spillCount);
-            var spillAmount = overflow.Volume / spillCount;
+            var spillAmount = overflow.Volume / args.NeighborFreeTiles.Count;
 
             foreach (var neighbor in args.NeighborFreeTiles)
             {
@@ -165,12 +158,10 @@ public sealed partial class PuddleSystem : SharedPuddleSystem
 
             foreach (var neighbor in args.Neighbors)
             {
-                // Overflow to neighbours but not if they're already at the cap
-                // This is to avoid diluting solutions too much.
+                // Overflow to neighbours (unless it's pure water)
                 if (!puddleQuery.TryGetComponent(neighbor, out var puddle) ||
                     !_solutionContainerSystem.TryGetSolution(neighbor, puddle.SolutionName, out var neighborSolution) ||
-                    CanFullyEvaporate(neighborSolution) ||
-                    neighborSolution.Volume >= puddle.OverflowVolume)
+                    CanFullyEvaporate(neighborSolution))
                 {
                     continue;
                 }
index c693632238aec11a8b581a62336f6f994d290a6f..161ea1469d19b5a4fa5762bc570e1ee33ea563e6 100644 (file)
@@ -11,6 +11,8 @@ public abstract class SharedPuddleSystem : EntitySystem
     /// </summary>
     public const float LowThreshold = 0.3f;
 
+    public const float MediumThreshold = 0.6f;
+
     public override void Initialize()
     {
         base.Initialize();