]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix eating the whole stack of uranium. (#41092)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Sun, 26 Oct 2025 00:58:17 +0000 (17:58 -0700)
committerGitHub <noreply@github.com>
Sun, 26 Oct 2025 00:58:17 +0000 (00:58 +0000)
* I hate stack system!!!

* a lil bit of fixing, as a treat

* humgry

* mmm burger

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Content.Shared/Nutrition/EntitySystems/IngestionSystem.cs
Content.Shared/Nutrition/IngestionEvents.cs
Content.Shared/Stacks/SharedStackSystem.cs

index d4050a17ce0bdb6629259002bc60462e36be4447..2373b6d9ea8d592905950372b6f6b967974ed497 100644 (file)
@@ -364,6 +364,9 @@ public sealed partial class IngestionSystem : EntitySystem
 
         var split = _solutionContainer.SplitSolution(solution.Value, transfer);
 
+        if (beforeEv.Refresh)
+            _solutionContainer.TryAddSolution(solution.Value, split);
+
         var ingestEv = new IngestingEvent(food, split, forceFed);
         RaiseLocalEvent(entity, ref ingestEv);
 
@@ -373,9 +376,6 @@ public sealed partial class IngestionSystem : EntitySystem
         var afterEv = new IngestedEvent(args.User, entity, split, forceFed);
         RaiseLocalEvent(food, ref afterEv);
 
-        if (afterEv.Refresh)
-            _solutionContainer.TryAddSolution(solution.Value, split);
-
         _stomach.TryTransferSolution(stomachToUse.Value.Owner, split, stomachToUse);
 
         if (!afterEv.Destroy)
index 27988c898db6f2466154401b3ab7b69448b198dd..afa50fc9319933582ba620eb2e61d3a58f0f5391 100644 (file)
@@ -111,6 +111,10 @@ public record struct BeforeIngestedEvent(FixedPoint2 Min, FixedPoint2 Max, Solut
     // Whether this event, and therefore eat attempt, should be cancelled.
     public bool Cancelled;
 
+    // When and if we eat this solution, should we actually remove solution or should it get replaced?
+    // This bool basically only exists because of stackable system.
+    public bool Refresh;
+
     public bool TryNewMinimum(FixedPoint2 newMin)
     {
         if (newMin > Max)
@@ -130,6 +134,12 @@ public record struct BeforeIngestedEvent(FixedPoint2 Min, FixedPoint2 Max, Solut
     }
 }
 
+/// <summary>
+/// Raised on an entity while it is eating
+/// </summary>
+/// <param name="Food">The item being ingested</param>
+/// <param name="Split">The solution being ingested</param>
+/// <param name="ForceFed">Whether or not we're being forced</param>
 [ByRefEvent]
 public record struct IngestingEvent(EntityUid Food, Solution Split, bool ForceFed);
 
@@ -143,10 +153,6 @@ public record struct IngestingEvent(EntityUid Food, Solution Split, bool ForceFe
 [ByRefEvent]
 public record struct IngestedEvent(EntityUid User, EntityUid Target, Solution Split, bool ForceFed)
 {
-    // Should we refill the solution now that we've eaten it?
-    // This bool basically only exists because of stackable system.
-    public bool Refresh;
-
     // Should we destroy the ingested entity?
     public bool Destroy;
 
index 83c55e08ea27b82ae346aeab8813db24caf2fd3a..a04fe579b0a302cddca7f19b344306c30f0b30d4 100644 (file)
@@ -30,7 +30,6 @@ public abstract partial class SharedStackSystem : EntitySystem
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] protected readonly SharedPopupSystem Popup = default!;
     [Dependency] private readonly SharedStorageSystem _storage = default!;
-    [Dependency] private readonly IGameTiming _timing = default!;
 
     // TODO: These should be in the prototype.
     public static readonly int[] DefaultSplitAmounts = { 1, 5, 10, 20, 30, 50 };
@@ -162,6 +161,9 @@ public abstract partial class SharedStackSystem : EntitySystem
             return;
         }
 
+        // If we've made it this far, we should refresh the solution when this item is eaten provided it's not the last one in the stack!
+        args.Refresh = eaten.Comp.Count > 1;
+
         /*
         Edible stacked items is near completely evil so we must choose one of the following:
         - Option 1: Eat the entire solution each bite and reduce the stack by 1.
@@ -178,18 +180,7 @@ public abstract partial class SharedStackSystem : EntitySystem
 
     private void OnEaten(Entity<StackComponent> eaten, ref IngestedEvent args)
     {
-        if (!TryUse(eaten.AsNullable(), 1))
-            return;
-
-        // We haven't eaten the whole stack yet or are unable to eat it completely.
-        if (eaten.Comp.Count > 0)
-        {
-            args.Refresh = true;
-            return;
-        }
-
-        // Here to tell the food system to do destroy stuff.
-        args.Destroy = true;
+        ReduceCount(eaten.AsNullable(), 1);
     }
 
     private void OnStackAlternativeInteract(Entity<StackComponent> ent, ref GetVerbsEvent<AlternativeVerb> args)