From bf627a6e80bd83f88e562eba28c4150b656adea9 Mon Sep 17 00:00:00 2001 From: Vyacheslav Kovalevsky <40753025+Slava0135@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:36:08 +1100 Subject: [PATCH 1/2] Cherry-picked commit 0d0edbba4a1c2af7ecef3318b5f9fe287a63fab5 from space-wizards/space-station-14/master --- .../Nutrition/EntitySystems/CreamPieSystem.cs | 15 +++++++++++---- .../EntitySystems/SliceableFoodSystem.cs | 3 +++ Content.Shared/Nutrition/Events.cs | 6 ++++++ .../Objects/Consumable/Food/Baked/pie.yml | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs index f8d781bcfff..a28679ddbc9 100644 --- a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs @@ -1,12 +1,11 @@ using Content.Server.Chemistry.Containers.EntitySystems; -using Content.Server.Explosion.Components; using Content.Server.Explosion.EntitySystems; using Content.Server.Fluids.EntitySystems; using Content.Server.Nutrition.Components; using Content.Server.Popups; using Content.Shared.Containers.ItemSlots; using Content.Shared.Explosion.Components; -using Content.Shared.Interaction; +using Content.Shared.Nutrition; using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.EntitySystems; using Content.Shared.Rejuvenate; @@ -32,7 +31,10 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnInteractUsing); + // activate BEFORE entity is deleted and trash is spawned + SubscribeLocalEvent(OnConsume, before: [typeof(FoodSystem)]); + SubscribeLocalEvent(OnSlice); + SubscribeLocalEvent(OnRejuvenate); } @@ -56,7 +58,12 @@ protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamP EntityManager.QueueDeleteEntity(uid); } - private void OnInteractUsing(Entity entity, ref InteractUsingEvent args) + private void OnConsume(Entity entity, ref ConsumeDoAfterEvent args) + { + ActivatePayload(entity); + } + + private void OnSlice(Entity entity, ref SliceFoodEvent args) { ActivatePayload(entity); } diff --git a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs index e92b046f2e3..d66d68f72d4 100644 --- a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Nutrition; // DeltaV using Content.Server.Chemistry.Containers.EntitySystems; using Content.Server.Nutrition.Components; +using Content.Shared.Nutrition; using Content.Shared.Nutrition.Components; using Content.Shared.Chemistry.Components; using Content.Shared.Examine; @@ -67,6 +68,8 @@ private bool TrySliceFood(EntityUid uid, EntityUid user, EntityUid usedItem, FillSlice(sliceUid, lostSolution); _audio.PlayPvs(component.Sound, transform.Coordinates, AudioParams.Default.WithVolume(-2)); + var ev = new SliceFoodEvent(); + RaiseLocalEvent(uid, ref ev); // Decrease size of item based on count - Could implement in the future // Bug with this currently is the size in a container is not updated diff --git a/Content.Shared/Nutrition/Events.cs b/Content.Shared/Nutrition/Events.cs index e27603763fa..f2936d603d9 100644 --- a/Content.Shared/Nutrition/Events.cs +++ b/Content.Shared/Nutrition/Events.cs @@ -53,3 +53,9 @@ public VapeDoAfterEvent(Solution solution, bool forced) public override DoAfterEvent Clone() => this; } + +/// +/// Raised before food is sliced +/// +[ByRefEvent] +public record struct SliceFoodEvent(); diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml index fe888595847..8cd1c5dfab6 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml @@ -156,6 +156,8 @@ path: /Audio/Weapons/Guns/Empty/empty.ogg ejectSound: path: /Audio/Weapons/Guns/Empty/empty.ogg + swap: false + disableEject: true - type: Tag tags: - Fruit From 6f0deef2d017943fe3dcf69e62c4e141d7cd7948 Mon Sep 17 00:00:00 2001 From: VMSolidus Date: Tue, 9 Jul 2024 20:02:59 -0400 Subject: [PATCH 2/2] Update SliceableFoodSystem.cs --- Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs index d66d68f72d4..dc848ccf9f1 100644 --- a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs @@ -68,8 +68,8 @@ private bool TrySliceFood(EntityUid uid, EntityUid user, EntityUid usedItem, FillSlice(sliceUid, lostSolution); _audio.PlayPvs(component.Sound, transform.Coordinates, AudioParams.Default.WithVolume(-2)); - var ev = new SliceFoodEvent(); - RaiseLocalEvent(uid, ref ev); + var ev = new SliceFoodEvent(uid, user, usedItem); + RaiseLocalEvent(ev); // Decrease size of item based on count - Could implement in the future // Bug with this currently is the size in a container is not updated