Make storage implant drop items on gibbing (#33493)
* Make storage implant drop items on gib/removal * Better way * Fix error * Forgotten trash * Cleanup * Unused var * Update Content.Server/Implants/ImplantedSystem.cs Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.co> Co-authored-by: 0x6273 <0x40@keemail.me>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Implants;
|
||||
@@ -9,6 +10,7 @@ public sealed partial class ImplanterSystem
|
||||
{
|
||||
SubscribeLocalEvent<ImplantedComponent, ComponentInit>(OnImplantedInit);
|
||||
SubscribeLocalEvent<ImplantedComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<ImplantedComponent, BeingGibbedEvent>(OnGibbed);
|
||||
}
|
||||
|
||||
private void OnImplantedInit(EntityUid uid, ImplantedComponent component, ComponentInit args)
|
||||
@@ -22,4 +24,10 @@ public sealed partial class ImplanterSystem
|
||||
//If the entity is deleted, get rid of the implants
|
||||
_container.CleanContainer(component.ImplantContainer);
|
||||
}
|
||||
|
||||
private void OnGibbed(Entity<ImplantedComponent> ent, ref BeingGibbedEvent args)
|
||||
{
|
||||
//If the entity is gibbed, get rid of the implants
|
||||
_container.CleanContainer(ent.Comp.ImplantContainer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -8,6 +7,7 @@ using Content.Shared.Tag;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Network;
|
||||
using System.Linq;
|
||||
|
||||
namespace Content.Shared.Implants;
|
||||
|
||||
@@ -17,6 +17,7 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
|
||||
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
|
||||
public const string BaseStorageId = "storagebase";
|
||||
|
||||
@@ -75,16 +76,11 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
|
||||
if (!_container.TryGetContainer(uid, BaseStorageId, out var storageImplant))
|
||||
return;
|
||||
|
||||
var entCoords = Transform(component.ImplantedEntity.Value).Coordinates;
|
||||
|
||||
var containedEntites = storageImplant.ContainedEntities.ToArray();
|
||||
|
||||
foreach (var entity in containedEntites)
|
||||
{
|
||||
if (Terminating(entity))
|
||||
continue;
|
||||
|
||||
_container.RemoveEntity(storageImplant.Owner, entity, force: true, destination: entCoords);
|
||||
_transformSystem.DropNextTo(entity, uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user