mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Implants-System-Predicted * popup * review * cleanup * I * ftl * fix test --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
38 lines
1.5 KiB
C#
38 lines
1.5 KiB
C#
using Content.Shared.Gibbing;
|
|
using Content.Shared.Implants.Components;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared.Implants;
|
|
|
|
public abstract partial class SharedImplanterSystem
|
|
{
|
|
public void InitializeImplanted()
|
|
{
|
|
SubscribeLocalEvent<ImplantedComponent, ComponentInit>(OnImplantedInit);
|
|
SubscribeLocalEvent<ImplantedComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<ImplantedComponent, GibbedBeforeDeletionEvent>(OnGibbed);
|
|
}
|
|
|
|
private void OnImplantedInit(Entity<ImplantedComponent> ent, ref ComponentInit args)
|
|
{
|
|
ent.Comp.ImplantContainer = _container.EnsureContainer<Container>(ent.Owner, ImplanterComponent.ImplantSlotId);
|
|
ent.Comp.ImplantContainer.OccludesLight = false;
|
|
}
|
|
|
|
private void OnShutdown(Entity<ImplantedComponent> ent, ref ComponentShutdown args)
|
|
{
|
|
// If the entity is deleted, get rid of the implants.
|
|
_container.CleanContainer(ent.Comp.ImplantContainer);
|
|
}
|
|
|
|
private void OnGibbed(Entity<ImplantedComponent> ent, ref GibbedBeforeDeletionEvent args)
|
|
{
|
|
// Drop the storage implant contents before the implants are deleted by the body being gibbed.
|
|
foreach (var implant in ent.Comp.ImplantContainer.ContainedEntities)
|
|
{
|
|
if (TryComp<StorageComponent>(implant, out var storage))
|
|
_container.EmptyContainer(storage.Container, destination: Transform(ent).Coordinates);
|
|
}
|
|
}
|
|
}
|