]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix cream pie bomb when eaten or sliced (#25928)
authorVyacheslav Kovalevsky <40753025+Slava0135@users.noreply.github.com>
Wed, 13 Mar 2024 08:36:08 +0000 (11:36 +0300)
committerGitHub <noreply@github.com>
Wed, 13 Mar 2024 08:36:08 +0000 (19:36 +1100)
* fix bomb activation when eaten

* no swap / no eject

* activate when sliced

Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs
Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs
Content.Shared/Nutrition/Events.cs
Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml

index f8d781bcfff6358729ca4eb6eab6485d12cafba8..a28679ddbc963cdeafb48b8678f858046d29e7c1 100644 (file)
@@ -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 @@ namespace Content.Server.Nutrition.EntitySystems
         {
             base.Initialize();
 
-            SubscribeLocalEvent<CreamPieComponent, InteractUsingEvent>(OnInteractUsing);
+            // activate BEFORE entity is deleted and trash is spawned
+            SubscribeLocalEvent<CreamPieComponent, ConsumeDoAfterEvent>(OnConsume, before: [typeof(FoodSystem)]);
+            SubscribeLocalEvent<CreamPieComponent, SliceFoodEvent>(OnSlice);
+
             SubscribeLocalEvent<CreamPiedComponent, RejuvenateEvent>(OnRejuvenate);
         }
 
@@ -56,7 +58,12 @@ namespace Content.Server.Nutrition.EntitySystems
             EntityManager.QueueDeleteEntity(uid);
         }
 
-        private void OnInteractUsing(Entity<CreamPieComponent> entity, ref InteractUsingEvent args)
+        private void OnConsume(Entity<CreamPieComponent> entity, ref ConsumeDoAfterEvent args)
+        {
+            ActivatePayload(entity);
+        }
+
+        private void OnSlice(Entity<CreamPieComponent> entity, ref SliceFoodEvent args)
         {
             ActivatePayload(entity);
         }
index 679b2cdbc23446e4a31cb930c2660a2cb610bb1e..e966daf5e58ed69b0ef3d05cf1b5a1287bfb3a91 100644 (file)
@@ -1,5 +1,6 @@
 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;
@@ -66,6 +67,8 @@ namespace Content.Server.Nutrition.EntitySystems
             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
index e27603763fa2f7519f95d24c41181c45c53057c6..f2936d603d9bca9584abd79fa998db8841697270 100644 (file)
@@ -53,3 +53,9 @@ public sealed partial class VapeDoAfterEvent : DoAfterEvent
 
     public override DoAfterEvent Clone() => this;
 }
+
+/// <summary>
+/// Raised before food is sliced
+/// </summary>
+[ByRefEvent]
+public record struct SliceFoodEvent();
index fe888595847e8a804d0ffa399984f26ed00b1835..8cd1c5dfab677f6eaed2504f2b39dbdcff60a7fb 100644 (file)
           path: /Audio/Weapons/Guns/Empty/empty.ogg
         ejectSound:
           path: /Audio/Weapons/Guns/Empty/empty.ogg
+        swap: false
+        disableEject: true
   - type: Tag
     tags:
     - Fruit