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.
This commit is contained in:
Doru991
2023-10-19 00:15:17 +03:00
committed by GitHub
parent 9c25db8b13
commit b419dbb3eb
3 changed files with 20 additions and 6 deletions

View File

@@ -111,7 +111,7 @@ public sealed class BodySystem : SharedBodySystem
_humanoidSystem.SetLayersVisibility(bodyUid, layers, false, true, humanoid); _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)) if (!Resolve(bodyId, ref body, false))
return new HashSet<EntityUid>(); return new HashSet<EntityUid>();
@@ -123,7 +123,7 @@ public sealed class BodySystem : SharedBodySystem
if (xform.MapUid == null) if (xform.MapUid == null)
return new HashSet<EntityUid>(); 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 coordinates = xform.Coordinates;
var filter = Filter.Pvs(bodyId, entityManager: EntityManager); var filter = Filter.Pvs(bodyId, entityManager: EntityManager);
@@ -135,7 +135,10 @@ public sealed class BodySystem : SharedBodySystem
{ {
if (deleteItems) if (deleteItems)
{ {
QueueDel(entity); if (!HasComp<BrainComponent>(entity) || deleteBrain)
{
QueueDel(entity);
}
} }
else else
{ {

View File

@@ -148,7 +148,7 @@ namespace Content.Server.Explosion.EntitySystems
if (!TryComp<TransformComponent>(uid, out var xform)) if (!TryComp<TransformComponent>(uid, out var xform))
return; return;
_body.GibBody(xform.ParentUid, deleteItems: component.DeleteItems); _body.GibBody(xform.ParentUid, true, deleteItems: component.DeleteItems);
args.Handled = true; args.Handled = true;
} }

View File

@@ -5,6 +5,8 @@ using Content.Shared.Body.Organ;
using Content.Shared.Body.Part; using Content.Shared.Body.Part;
using Content.Shared.Body.Prototypes; using Content.Shared.Body.Prototypes;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map; 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. * - 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() private void InitializeBody()
{ {
// Body here to handle root body parts. // 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, 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>(); var gibs = new HashSet<EntityUid>();
@@ -287,7 +291,14 @@ public partial class SharedBodySystem
gibs.Add(organ.Id); 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; return gibs;
} }
} }