]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix `StomachSystem` PVS error (#38268)
authorTayrtahn <tayrtahn@gmail.com>
Wed, 11 Jun 2025 21:39:25 +0000 (17:39 -0400)
committerGitHub <noreply@github.com>
Wed, 11 Jun 2025 21:39:25 +0000 (23:39 +0200)
Fix StomachSystem PVS error

Content.Shared/Body/Systems/StomachSystem.cs

index 935dda6389a0c122960590ca2d2ed0bbd2ee0030..8b2df453a02f16dbf5d31c4a6233fc83641cbc4f 100644 (file)
@@ -4,6 +4,7 @@ using Content.Shared.Body.Organ;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.EntitySystems;
+using Robust.Shared.Containers;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 
@@ -20,6 +21,7 @@ namespace Content.Shared.Body.Systems
         {
             SubscribeLocalEvent<StomachComponent, MapInitEvent>(OnMapInit);
             SubscribeLocalEvent<StomachComponent, EntityUnpausedEvent>(OnUnpaused);
+            SubscribeLocalEvent<StomachComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
             SubscribeLocalEvent<StomachComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
         }
 
@@ -33,6 +35,16 @@ namespace Content.Shared.Body.Systems
             ent.Comp.NextUpdate += args.PausedTime;
         }
 
+        private void OnEntRemoved(Entity<StomachComponent> ent, ref EntRemovedFromContainerMessage args)
+        {
+            // Make sure the removed entity was our contained solution
+            if (ent.Comp.Solution is not { } solution || args.Entity != solution.Owner)
+                return;
+
+            // Cleared our cached reference to the solution entity
+            ent.Comp.Solution = null;
+        }
+
         public override void Update(float frameTime)
         {
             var query = EntityQueryEnumerator<StomachComponent, OrganComponent, SolutionContainerManagerComponent>();