Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make storage implant drop items on gibbing #33493

Merged
merged 7 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading