]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make storage implant drop items on gibbing (#33493)
authorWinkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Sun, 19 Jan 2025 19:48:58 +0000 (22:48 +0300)
committerGitHub <noreply@github.com>
Sun, 19 Jan 2025 19:48:58 +0000 (11:48 -0800)
* 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>
Content.Server/Implants/ImplantedSystem.cs
Content.Shared/Implants/SharedSubdermalImplantSystem.cs

index 5d27e6471185fb9a48c4c6272bdea4a49df3d526..16b2c79d25f49f1b99183259bb2c06c60e20e420 100644 (file)
@@ -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);
+    }
 }
index 94203de615583bd9e6f32fddebc1418f417c3dbc..bb166b3c5cb8c5b2c7894ee25d9766c872c3e325 100644 (file)
@@ -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);
         }
     }