Skip to content

Commit

Permalink
Make storage implant drop items on gibbing (#33493)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Winkarst <[email protected]>
Co-authored-by: 0x6273 <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2025
1 parent 2894f49 commit b09cd1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 9 additions & 1 deletion Content.Server/Implants/ImplantedSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,6 +10,7 @@ public void InitializeImplanted()
{
SubscribeLocalEvent<ImplantedComponent, ComponentInit>(OnImplantedInit);
SubscribeLocalEvent<ImplantedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ImplantedComponent, BeingGibbedEvent>(OnGibbed);
}

private void OnImplantedInit(EntityUid uid, ImplantedComponent component, ComponentInit args)
Expand All @@ -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<ImplantedComponent> ent, ref BeingGibbedEvent args)
{
//If the entity is gibbed, get rid of the implants
_container.CleanContainer(ent.Comp.ImplantContainer);
}
}
10 changes: 3 additions & 7 deletions Content.Shared/Implants/SharedSubdermalImplantSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using Content.Shared.Actions;
using Content.Shared.Implants.Components;
using Content.Shared.Interaction;
Expand All @@ -8,6 +7,7 @@
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using System.Linq;

namespace Content.Shared.Implants;

Expand All @@ -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";

Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b09cd1c

Please sign in to comment.