early merge of microbomb fix (#2905)
Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
parent
a4b3642337
commit
a5b0f65431
|
|
@ -1,5 +1,6 @@
|
||||||
using Content.Server.Body.Components;
|
using Content.Server.Body.Components;
|
||||||
using Content.Shared.Implants.Components;
|
using Content.Shared.Implants.Components;
|
||||||
|
using Content.Shared.Storage;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
namespace Content.Server.Implants;
|
namespace Content.Server.Implants;
|
||||||
|
|
@ -13,21 +14,26 @@ public sealed partial class ImplanterSystem
|
||||||
SubscribeLocalEvent<ImplantedComponent, BeingGibbedEvent>(OnGibbed);
|
SubscribeLocalEvent<ImplantedComponent, BeingGibbedEvent>(OnGibbed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnImplantedInit(EntityUid uid, ImplantedComponent component, ComponentInit args)
|
private void OnImplantedInit(Entity<ImplantedComponent> ent, ref ComponentInit args)
|
||||||
{
|
{
|
||||||
component.ImplantContainer = _container.EnsureContainer<Container>(uid, ImplanterComponent.ImplantSlotId);
|
ent.Comp.ImplantContainer = _container.EnsureContainer<Container>(ent.Owner, ImplanterComponent.ImplantSlotId);
|
||||||
component.ImplantContainer.OccludesLight = false;
|
ent.Comp.ImplantContainer.OccludesLight = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnShutdown(EntityUid uid, ImplantedComponent component, ComponentShutdown args)
|
private void OnShutdown(Entity<ImplantedComponent> ent, ref ComponentShutdown args)
|
||||||
{
|
{
|
||||||
//If the entity is deleted, get rid of the implants
|
//If the entity is deleted, get rid of the implants
|
||||||
_container.CleanContainer(component.ImplantContainer);
|
_container.CleanContainer(ent.Comp.ImplantContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGibbed(Entity<ImplantedComponent> ent, ref BeingGibbedEvent args)
|
private void OnGibbed(Entity<ImplantedComponent> ent, ref BeingGibbedEvent args)
|
||||||
{
|
{
|
||||||
//If the entity is gibbed, get rid of the implants
|
// Drop the storage implant contents before the implants are deleted by the body being gibbed
|
||||||
_container.CleanContainer(ent.Comp.ImplantContainer);
|
foreach (var implant in ent.Comp.ImplantContainer.ContainedEntities)
|
||||||
|
{
|
||||||
|
if (TryComp<StorageComponent>(implant, out var storage))
|
||||||
|
_container.EmptyContainer(storage.Container, destination: Transform(ent).Coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ namespace Content.Shared.Implants.Components;
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class ImplantedComponent : Component
|
public sealed partial class ImplantedComponent : Component
|
||||||
{
|
{
|
||||||
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public Container ImplantContainer = default!;
|
public Container ImplantContainer = default!;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue