1
1
using Content . Server . Body . Components ;
2
2
using Content . Shared . Implants . Components ;
3
+ using Content . Shared . Storage ;
3
4
using Robust . Shared . Containers ;
4
5
5
6
namespace Content . Server . Implants ;
@@ -13,21 +14,26 @@ public void InitializeImplanted()
13
14
SubscribeLocalEvent < ImplantedComponent , BeingGibbedEvent > ( OnGibbed ) ;
14
15
}
15
16
16
- private void OnImplantedInit ( EntityUid uid , ImplantedComponent component , ComponentInit args )
17
+ private void OnImplantedInit ( Entity < ImplantedComponent > ent , ref ComponentInit args )
17
18
{
18
- component . ImplantContainer = _container . EnsureContainer < Container > ( uid , ImplanterComponent . ImplantSlotId ) ;
19
- component . ImplantContainer . OccludesLight = false ;
19
+ ent . Comp . ImplantContainer = _container . EnsureContainer < Container > ( ent . Owner , ImplanterComponent . ImplantSlotId ) ;
20
+ ent . Comp . ImplantContainer . OccludesLight = false ;
20
21
}
21
22
22
- private void OnShutdown ( EntityUid uid , ImplantedComponent component , ComponentShutdown args )
23
+ private void OnShutdown ( Entity < ImplantedComponent > ent , ref ComponentShutdown args )
23
24
{
24
25
//If the entity is deleted, get rid of the implants
25
- _container . CleanContainer ( component . ImplantContainer ) ;
26
+ _container . CleanContainer ( ent . Comp . ImplantContainer ) ;
26
27
}
27
28
28
29
private void OnGibbed ( Entity < ImplantedComponent > ent , ref BeingGibbedEvent args )
29
30
{
30
- //If the entity is gibbed, get rid of the implants
31
- _container . CleanContainer ( ent . Comp . ImplantContainer ) ;
31
+ // Drop the storage implant contents before the implants are deleted by the body being gibbed
32
+ foreach ( var implant in ent . Comp . ImplantContainer . ContainedEntities )
33
+ {
34
+ if ( TryComp < StorageComponent > ( implant , out var storage ) )
35
+ _container . EmptyContainer ( storage . Container , destination : Transform ( ent ) . Coordinates ) ;
36
+ }
37
+
32
38
}
33
39
}
0 commit comments