]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make gibbing drop items again (#21047)
authorDoru991 <75124791+Doru991@users.noreply.github.com>
Wed, 18 Oct 2023 21:15:17 +0000 (00:15 +0300)
committerGitHub <noreply@github.com>
Wed, 18 Oct 2023 21:15:17 +0000 (14:15 -0700)
LGTM, Just a warning that this will probably get overriden when medical refactor gets merged since it refactors gibbing.

Content.Server/Body/Systems/BodySystem.cs
Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Content.Shared/Body/Systems/SharedBodySystem.Body.cs

index 2010537e34bf946cb53808dbde7db4a869d4b3ea..f2f848c488d7d961ffa2fb5fdbb9e8fec5b4f3e0 100644 (file)
@@ -111,7 +111,7 @@ public sealed class BodySystem : SharedBodySystem
         _humanoidSystem.SetLayersVisibility(bodyUid, layers, false, true, humanoid);
     }
 
-    public override HashSet<EntityUid> GibBody(EntityUid bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false)
+    public override HashSet<EntityUid> GibBody(EntityUid bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false, bool deleteBrain = false)
     {
         if (!Resolve(bodyId, ref body, false))
             return new HashSet<EntityUid>();
@@ -123,7 +123,7 @@ public sealed class BodySystem : SharedBodySystem
         if (xform.MapUid == null)
             return new HashSet<EntityUid>();
 
-        var gibs = base.GibBody(bodyId, gibOrgans, body, deleteItems);
+        var gibs = base.GibBody(bodyId, gibOrgans, body, deleteItems, deleteBrain);
 
         var coordinates = xform.Coordinates;
         var filter = Filter.Pvs(bodyId, entityManager: EntityManager);
@@ -135,7 +135,10 @@ public sealed class BodySystem : SharedBodySystem
         {
             if (deleteItems)
             {
-                QueueDel(entity);
+                if (!HasComp<BrainComponent>(entity) || deleteBrain)
+                {
+                    QueueDel(entity);
+                }
             }
             else
             {
index 91b32af870818faa64c0dcf0a0ec356734c81376..b57e9bd29872050d74b97432fa1b34da5b9c451e 100644 (file)
@@ -148,7 +148,7 @@ namespace Content.Server.Explosion.EntitySystems
             if (!TryComp<TransformComponent>(uid, out var xform))
                 return;
 
-            _body.GibBody(xform.ParentUid, deleteItems: component.DeleteItems);
+            _body.GibBody(xform.ParentUid, true, deleteItems: component.DeleteItems);
 
             args.Handled = true;
         }
index 8f16ca8efc451479ea93e74426c92aeaab992415..74a202386ec45abaf771ec401c5caf662eefdfe6 100644 (file)
@@ -5,6 +5,8 @@ using Content.Shared.Body.Organ;
 using Content.Shared.Body.Part;
 using Content.Shared.Body.Prototypes;
 using Content.Shared.DragDrop;
+using Content.Shared.Inventory;
+using Content.Shared.Inventory.Events;
 using Robust.Shared.Containers;
 using Robust.Shared.Map;
 
@@ -19,6 +21,8 @@ public partial class SharedBodySystem
      * - Each "connection" is a body part (e.g. arm, hand, etc.) and each part can also contain organs.
      */
 
+    [Dependency] private readonly InventorySystem _inventory = default!;
+
     private void InitializeBody()
     {
         // Body here to handle root body parts.
@@ -263,7 +267,7 @@ public partial class SharedBodySystem
     }
 
     public virtual HashSet<EntityUid> GibBody(EntityUid bodyId, bool gibOrgans = false,
-        BodyComponent? body = null, bool deleteItems = false)
+        BodyComponent? body = null, bool deleteItems = false, bool deleteBrain = false)
     {
         var gibs = new HashSet<EntityUid>();
 
@@ -287,7 +291,14 @@ public partial class SharedBodySystem
                 gibs.Add(organ.Id);
             }
         }
-
+        if(TryComp<InventoryComponent>(bodyId, out var inventory))
+        {
+            foreach (var item in _inventory.GetHandOrInventoryEntities(bodyId))
+            {
+                SharedTransform.AttachToGridOrMap(item);
+                gibs.Add(item);
+            }
+        }
         return gibs;
     }
 }