]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
[HOTFIX] Fix Burgers (#39773)
authorPrincess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
Sat, 6 Sep 2025 09:18:06 +0000 (02:18 -0700)
committerPrincess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Sat, 6 Sep 2025 09:19:19 +0000 (02:19 -0700)
* Borgar

* Review

* Predicted queuedel

* Predict

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs
Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs
Content.Shared/Nutrition/EntitySystems/IngestionSystem.API.cs
Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs
Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml

index e85393e6f7a23c33edfe8b56e49129630f8f9bae..7164c701f548151c10ec0962128c17b082daa545 100644 (file)
@@ -21,12 +21,13 @@ namespace Content.Server.Nutrition.EntitySystems
     [UsedImplicitly]
     public sealed class CreamPieSystem : SharedCreamPieSystem
     {
-        [Dependency] private readonly SharedSolutionContainerSystem _solutions = default!;
-        [Dependency] private readonly PuddleSystem _puddle = default!;
+        [Dependency] private readonly IngestionSystem _ingestion = default!;
         [Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
-        [Dependency] private readonly TriggerSystem _trigger = default!;
-        [Dependency] private readonly SharedAudioSystem _audio = default!;
         [Dependency] private readonly PopupSystem _popup = default!;
+        [Dependency] private readonly PuddleSystem _puddle = default!;
+        [Dependency] private readonly SharedAudioSystem _audio = default!;
+        [Dependency] private readonly SharedSolutionContainerSystem _solutions = default!;
+        [Dependency] private readonly TriggerSystem _trigger = default!;
 
         public override void Initialize()
         {
@@ -39,26 +40,23 @@ namespace Content.Server.Nutrition.EntitySystems
             SubscribeLocalEvent<CreamPiedComponent, RejuvenateEvent>(OnRejuvenate);
         }
 
-        protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie)
+        protected override void SplattedCreamPie(Entity<CreamPieComponent, EdibleComponent?> entity)
         {
             // The entity is deleted, so play the sound at its position rather than parenting
-            var coordinates = Transform(uid).Coordinates;
-            _audio.PlayPvs(_audio.ResolveSound(creamPie.Sound), coordinates, AudioParams.Default.WithVariation(0.125f));
+            var coordinates = Transform(entity).Coordinates;
+            _audio.PlayPvs(_audio.ResolveSound(entity.Comp1.Sound), coordinates, AudioParams.Default.WithVariation(0.125f));
 
-            if (TryComp(uid, out FoodComponent? foodComp))
+            if (Resolve(entity, ref entity.Comp2, false))
             {
-                if (_solutions.TryGetSolution(uid, foodComp.Solution, out _, out var solution))
-                {
-                    _puddle.TrySpillAt(uid, solution, out _, false);
-                }
-                foreach (var trash in foodComp.Trash)
-                {
-                    Spawn(trash, Transform(uid).Coordinates);
-                }
+                if (_solutions.TryGetSolution(entity.Owner, entity.Comp2.Solution, out _, out var solution))
+                    _puddle.TrySpillAt(entity.Owner, solution, out _, false);
+
+                _ingestion.SpawnTrash((entity, entity.Comp2));
             }
-            ActivatePayload(uid);
 
-            QueueDel(uid);
+            ActivatePayload(entity);
+
+            QueueDel(entity);
         }
 
         private void OnConsume(Entity<CreamPieComponent> entity, ref ConsumeDoAfterEvent args)
index 7b50ae2c8bfabcabd82ce7991e19e235e6b15ee5..0fa85666a027be2534737fa159a66581a194fd4a 100644 (file)
@@ -15,14 +15,15 @@ namespace Content.Shared.Nutrition.EntitySystems;
 
 public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
 {
-    [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
-    [Dependency] private readonly SharedPopupSystem _popup = default!;
-    [Dependency] private readonly MetaDataSystem _metaData = default!;
-    [Dependency] private readonly MobStateSystem _mobState = default!;
-    [Dependency] private readonly TagSystem _tag = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly IPrototypeManager _proto = default!;
+    [Dependency] private readonly MetaDataSystem _metaData = default!;
+    [Dependency] private readonly MobStateSystem _mobState = default!;
+    [Dependency] private readonly IngestionSystem _ingestion = default!;
+    [Dependency] private readonly SharedPopupSystem _popup = default!;
+    [Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
+    [Dependency] private readonly TagSystem _tag = default!;
 
     public override void Initialize()
     {
@@ -78,13 +79,13 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
             return true;
 
         Metamorf(start, _random.Pick(availableRecipes)); //In general, if there's more than one recipe, the yml-guys screwed up. Maybe some kind of unit test is needed.
-        QueueDel(start);
+        PredictedQueueDel(start.Owner);
         return true;
     }
 
     private void Metamorf(Entity<FoodSequenceStartPointComponent> start, MetamorphRecipePrototype recipe)
     {
-        var result = SpawnAtPosition(recipe.Result, Transform(start).Coordinates);
+        var result = PredictedSpawnNextToOrDrop(recipe.Result, start);
 
         //Try putting in container
         _transform.DropNextTo(result, (start, Transform(start)));
@@ -100,21 +101,23 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
         _solutionContainer.TryAddSolution(resultSoln.Value, startSolution);
 
         MergeFlavorProfiles(start, result);
-        MergeTrash(start, result);
+        MergeTrash(start.Owner, result);
         MergeTags(start, result);
     }
 
-    private bool TryAddFoodElement(Entity<FoodSequenceStartPointComponent> start, Entity<FoodSequenceElementComponent> element, EntityUid? user = null)
+    private bool TryAddFoodElement(Entity<FoodSequenceStartPointComponent> start, Entity<FoodSequenceElementComponent, EdibleComponent?> element, EntityUid? user = null)
     {
         // we can't add a live mouse to a burger.
-        if (!TryComp<FoodComponent>(element, out var elementFood))
+        if (!Resolve(element, ref element.Comp2, false))
             return false;
-        if (elementFood.RequireDead && _mobState.IsAlive(element))
+
+        if (element.Comp2.RequireDead && _mobState.IsAlive(element))
             return false;
 
         //looking for a suitable FoodSequence prototype
-        if (!element.Comp.Entries.TryGetValue(start.Comp.Key, out var elementProto))
+        if (!element.Comp1.Entries.TryGetValue(start.Comp.Key, out var elementProto))
             return false;
+
         if (!_proto.TryIndex(elementProto, out var elementIndexed))
             return false;
 
@@ -150,15 +153,15 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
             start.Comp.Finished = true;
 
         UpdateFoodName(start);
-        MergeFoodSolutions(start, element);
+        MergeFoodSolutions(start.Owner, element.Owner);
         MergeFlavorProfiles(start, element);
-        MergeTrash(start, element);
+        MergeTrash(start.Owner, element.Owner);
         MergeTags(start, element);
 
         var ev = new FoodSequenceIngredientAddedEvent(start, element, elementProto, user);
         RaiseLocalEvent(start, ev);
 
-        QueueDel(element);
+        PredictedQueueDel(element.Owner);
         return true;
     }
 
@@ -203,18 +206,18 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
         _metaData.SetEntityName(start, newName);
     }
 
-    private void MergeFoodSolutions(EntityUid start, EntityUid element)
+    private void MergeFoodSolutions(Entity<EdibleComponent?> start, Entity<EdibleComponent?> element)
     {
-        if (!TryComp<FoodComponent>(start, out var startFood))
+        if (!Resolve(start, ref start.Comp, false))
             return;
 
-        if (!TryComp<FoodComponent>(element, out var elementFood))
+        if (!Resolve(element, ref element.Comp, false))
             return;
 
-        if (!_solutionContainer.TryGetSolution(start, startFood.Solution, out var startSolutionEntity, out var startSolution))
+        if (!_solutionContainer.TryGetSolution(start.Owner, start.Comp.Solution, out var startSolutionEntity, out var startSolution))
             return;
 
-        if (!_solutionContainer.TryGetSolution(element, elementFood.Solution, out _, out var elementSolution))
+        if (!_solutionContainer.TryGetSolution(element.Owner, element.Comp.Solution, out _, out var elementSolution))
             return;
 
         startSolution.MaxVolume += elementSolution.MaxVolume;
@@ -236,18 +239,15 @@ public sealed class FoodSequenceSystem : SharedFoodSequenceSystem
         }
     }
 
-    private void MergeTrash(EntityUid start, EntityUid element)
+    private void MergeTrash(Entity<EdibleComponent?> start, Entity<EdibleComponent?> element)
     {
-        if (!TryComp<FoodComponent>(start, out var startFood))
+        if (!Resolve(start, ref start.Comp, false))
             return;
 
-        if (!TryComp<FoodComponent>(element, out var elementFood))
+        if (!Resolve(element, ref element.Comp, false))
             return;
 
-        foreach (var trash in elementFood.Trash)
-        {
-            startFood.Trash.Add(trash);
-        }
+        _ingestion.AddTrash((start, start.Comp), element.Comp.Trash);
     }
 
     private void MergeTags(EntityUid start, EntityUid element)
index 3a8ef333d7f04c1ce4cced222838744db86d83b7..990c8105c52a5b209a1a7819541cef2d91671d06 100644 (file)
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
 using Content.Shared.Chemistry.Components;
 using Content.Shared.Chemistry.Components.SolutionManager;
 using Content.Shared.Chemistry.Reagent;
@@ -140,25 +141,35 @@ public sealed partial class IngestionSystem
 
     #region EdibleComponent
 
-    public void SpawnTrash(Entity<EdibleComponent> entity, EntityUid user)
+    public void SpawnTrash(Entity<EdibleComponent> entity, EntityUid? user = null)
     {
         if (entity.Comp.Trash.Count == 0)
             return;
 
         var position = _transform.GetMapCoordinates(entity);
         var trashes = entity.Comp.Trash;
-        var tryPickup = _hands.IsHolding(user, entity, out _);
+        var pickup = user != null && _hands.IsHolding(user.Value, entity, out _);
 
         foreach (var trash in trashes)
         {
             var spawnedTrash = EntityManager.PredictedSpawn(trash, position);
 
             // If the user is holding the item
-            if (tryPickup)
-            {
-                // Put the trash in the user's hand
-                _hands.TryPickupAnyHand(user, spawnedTrash);
-            }
+            if (!pickup)
+                continue;
+
+            // Put the trash in the user's hand
+            // I am 100% confident we don't need this check but rider gets made at me if it's not here.
+            if (user != null)
+                _hands.TryPickupAnyHand(user.Value, spawnedTrash);
+        }
+    }
+
+    public void AddTrash(Entity<EdibleComponent> entity, List<EntProtoId> newTrash)
+    {
+        foreach (var trash in newTrash)
+        {
+            entity.Comp.Trash.Add(trash);
         }
     }
 
index 86eec26bfd295935f0ea2a35ba91eca866a4d365..a0a82d63effd87f648cfb6cfc5ca6da013969897 100644 (file)
@@ -20,18 +20,18 @@ namespace Content.Shared.Nutrition.EntitySystems
             SubscribeLocalEvent<CreamPiedComponent, ThrowHitByEvent>(OnCreamPiedHitBy);
         }
 
-        public void SplatCreamPie(EntityUid uid, CreamPieComponent creamPie)
+        public void SplatCreamPie(Entity<CreamPieComponent> creamPie)
         {
             // Already splatted! Do nothing.
-            if (creamPie.Splatted)
+            if (creamPie.Comp.Splatted)
                 return;
 
-            creamPie.Splatted = true;
+            creamPie.Comp.Splatted = true;
 
-            SplattedCreamPie(uid, creamPie);
+            SplattedCreamPie(creamPie);
         }
 
-        protected virtual void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie) {}
+        protected virtual void SplattedCreamPie(Entity<CreamPieComponent, EdibleComponent?> entity) { }
 
         public void SetCreamPied(EntityUid uid, CreamPiedComponent creamPied, bool value)
         {
@@ -46,14 +46,14 @@ namespace Content.Shared.Nutrition.EntitySystems
             }
         }
 
-        private void OnCreamPieLand(EntityUid uid, CreamPieComponent component, ref LandEvent args)
+        private void OnCreamPieLand(Entity<CreamPieComponent> entity, ref LandEvent args)
         {
-            SplatCreamPie(uid, component);
+            SplatCreamPie(entity);
         }
 
-        private void OnCreamPieHit(EntityUid uid, CreamPieComponent component, ThrowDoHitEvent args)
+        private void OnCreamPieHit(Entity<CreamPieComponent> entity, ref ThrowDoHitEvent args)
         {
-            SplatCreamPie(uid, component);
+            SplatCreamPie(entity);
         }
 
         private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
index c031559b58efaff19ef2cb20881401e122ff8814..211bf12b1656f627a64c63f622a8988f33f76e08 100644 (file)
@@ -24,7 +24,7 @@
           Quantity: 14
         - ReagentId: Sugar
           Quantity: 5
-  - type: Food #All pies here made with a pie tin; unless you're some kind of savage, you're probably not destroying this when you eat or slice the pie!
+  - type: Edible #It's actually possible now to have a pie stored in a tin rather than spawning trash when you finish eating it. But right now I'm just cleaning up.
     trash:
     - FoodPlateTin
   - type: SliceableFood