From 9a10a190721fe0d2394a025529c2f6cf777afde3 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Sat, 25 Oct 2025 17:58:17 -0700 Subject: [PATCH] Fix eating the whole stack of uranium. (#41092) * 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> --- .../Nutrition/EntitySystems/IngestionSystem.cs | 6 +++--- Content.Shared/Nutrition/IngestionEvents.cs | 14 ++++++++++---- Content.Shared/Stacks/SharedStackSystem.cs | 17 ++++------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Content.Shared/Nutrition/EntitySystems/IngestionSystem.cs b/Content.Shared/Nutrition/EntitySystems/IngestionSystem.cs index d4050a17ce..2373b6d9ea 100644 --- a/Content.Shared/Nutrition/EntitySystems/IngestionSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/IngestionSystem.cs @@ -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) diff --git a/Content.Shared/Nutrition/IngestionEvents.cs b/Content.Shared/Nutrition/IngestionEvents.cs index 27988c898d..afa50fc931 100644 --- a/Content.Shared/Nutrition/IngestionEvents.cs +++ b/Content.Shared/Nutrition/IngestionEvents.cs @@ -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 } } +/// +/// Raised on an entity while it is eating +/// +/// The item being ingested +/// The solution being ingested +/// Whether or not we're being forced [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; diff --git a/Content.Shared/Stacks/SharedStackSystem.cs b/Content.Shared/Stacks/SharedStackSystem.cs index 83c55e08ea..a04fe579b0 100644 --- a/Content.Shared/Stacks/SharedStackSystem.cs +++ b/Content.Shared/Stacks/SharedStackSystem.cs @@ -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 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 ent, ref GetVerbsEvent args)