diff --git a/Content.Server/Implants/ImplantedSystem.cs b/Content.Server/Implants/ImplantedSystem.cs index 5d27e6471185..16b2c79d25f4 100644 --- a/Content.Server/Implants/ImplantedSystem.cs +++ b/Content.Server/Implants/ImplantedSystem.cs @@ -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 void InitializeImplanted() { SubscribeLocalEvent(OnImplantedInit); SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnGibbed); } private void OnImplantedInit(EntityUid uid, ImplantedComponent component, ComponentInit args) @@ -22,4 +24,10 @@ private void OnShutdown(EntityUid uid, ImplantedComponent component, ComponentSh //If the entity is deleted, get rid of the implants _container.CleanContainer(component.ImplantContainer); } + + private void OnGibbed(Entity ent, ref BeingGibbedEvent args) + { + //If the entity is gibbed, get rid of the implants + _container.CleanContainer(ent.Comp.ImplantContainer); + } } diff --git a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs index 94203de61558..bb166b3c5cb8 100644 --- a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs +++ b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs @@ -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 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 @@ private void OnRemove(EntityUid uid, SubdermalImplantComponent component, EntGot 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); } }