From 8a1a1b98c441bc47034827f267fafc787d321466 Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Sat, 6 Sep 2025 02:18:06 -0700 Subject: [PATCH] [HOTFIX] Fix Burgers (#39773) * Borgar * Review * Predicted queuedel * Predict --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> --- .../Nutrition/EntitySystems/CreamPieSystem.cs | 34 ++++++------ .../EntitySystems/FoodSequenceSystem.cs | 54 +++++++++---------- .../EntitySystems/IngestionSystem.API.cs | 27 +++++++--- .../EntitySystems/SharedCreamPieSystem.cs | 18 +++---- .../Objects/Consumable/Food/Baked/pie.yml | 2 +- 5 files changed, 72 insertions(+), 63 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs index e85393e6f7..7164c701f5 100644 --- a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs @@ -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(OnRejuvenate); } - protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie) + protected override void SplattedCreamPie(Entity 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 entity, ref ConsumeDoAfterEvent args) diff --git a/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs b/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs index 7b50ae2c8b..0fa85666a0 100644 --- a/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/FoodSequenceSystem.cs @@ -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 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 start, Entity element, EntityUid? user = null) + private bool TryAddFoodElement(Entity start, Entity element, EntityUid? user = null) { // we can't add a live mouse to a burger. - if (!TryComp(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 start, Entity element) { - if (!TryComp(start, out var startFood)) + if (!Resolve(start, ref start.Comp, false)) return; - if (!TryComp(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 start, Entity element) { - if (!TryComp(start, out var startFood)) + if (!Resolve(start, ref start.Comp, false)) return; - if (!TryComp(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) diff --git a/Content.Shared/Nutrition/EntitySystems/IngestionSystem.API.cs b/Content.Shared/Nutrition/EntitySystems/IngestionSystem.API.cs index 3a8ef333d7..990c8105c5 100644 --- a/Content.Shared/Nutrition/EntitySystems/IngestionSystem.API.cs +++ b/Content.Shared/Nutrition/EntitySystems/IngestionSystem.API.cs @@ -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 entity, EntityUid user) + public void SpawnTrash(Entity 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 entity, List newTrash) + { + foreach (var trash in newTrash) + { + entity.Comp.Trash.Add(trash); } } diff --git a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs index 86eec26bfd..a0a82d63ef 100644 --- a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs @@ -20,18 +20,18 @@ namespace Content.Shared.Nutrition.EntitySystems SubscribeLocalEvent(OnCreamPiedHitBy); } - public void SplatCreamPie(EntityUid uid, CreamPieComponent creamPie) + public void SplatCreamPie(Entity 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 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 entity, ref LandEvent args) { - SplatCreamPie(uid, component); + SplatCreamPie(entity); } - private void OnCreamPieHit(EntityUid uid, CreamPieComponent component, ThrowDoHitEvent args) + private void OnCreamPieHit(Entity entity, ref ThrowDoHitEvent args) { - SplatCreamPie(uid, component); + SplatCreamPie(entity); } private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml index c031559b58..211bf12b16 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml @@ -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 -- 2.51.2