From b419dbb3eb85f7fe542d275ff921460cbec79b94 Mon Sep 17 00:00:00 2001 From: Doru991 <75124791+Doru991@users.noreply.github.com> Date: Thu, 19 Oct 2023 00:15:17 +0300 Subject: [PATCH] Make gibbing drop items again (#21047) 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 | 9 ++++++--- .../Explosion/EntitySystems/TriggerSystem.cs | 2 +- .../Body/Systems/SharedBodySystem.Body.cs | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Content.Server/Body/Systems/BodySystem.cs b/Content.Server/Body/Systems/BodySystem.cs index 2010537e34..f2f848c488 100644 --- a/Content.Server/Body/Systems/BodySystem.cs +++ b/Content.Server/Body/Systems/BodySystem.cs @@ -111,7 +111,7 @@ public sealed class BodySystem : SharedBodySystem _humanoidSystem.SetLayersVisibility(bodyUid, layers, false, true, humanoid); } - public override HashSet GibBody(EntityUid bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false) + public override HashSet GibBody(EntityUid bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false, bool deleteBrain = false) { if (!Resolve(bodyId, ref body, false)) return new HashSet(); @@ -123,7 +123,7 @@ public sealed class BodySystem : SharedBodySystem if (xform.MapUid == null) return new HashSet(); - 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(entity) || deleteBrain) + { + QueueDel(entity); + } } else { diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index 91b32af870..b57e9bd298 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -148,7 +148,7 @@ namespace Content.Server.Explosion.EntitySystems if (!TryComp(uid, out var xform)) return; - _body.GibBody(xform.ParentUid, deleteItems: component.DeleteItems); + _body.GibBody(xform.ParentUid, true, deleteItems: component.DeleteItems); args.Handled = true; } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 8f16ca8efc..74a202386e 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -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 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(); @@ -287,7 +291,14 @@ public partial class SharedBodySystem gibs.Add(organ.Id); } } - + if(TryComp(bodyId, out var inventory)) + { + foreach (var item in _inventory.GetHandOrInventoryEntities(bodyId)) + { + SharedTransform.AttachToGridOrMap(item); + gibs.Add(item); + } + } return gibs; } } -- 2.51.2