mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using System.Linq;
|
|
using Content.Shared.Implants.Components;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Shared.Implants;
|
|
|
|
public sealed partial class StorageImplantSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedContainerSystem _container = default!;
|
|
[Dependency] private SharedTransformSystem _transform = default!;
|
|
[Dependency] private INetManager _net = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<StorageImplantComponent, ImplantRemovedEvent>(OnImplantRemoved);
|
|
}
|
|
|
|
private void OnImplantRemoved(Entity<StorageImplantComponent> ent, ref ImplantRemovedEvent args)
|
|
{
|
|
if (_net.IsClient)
|
|
return; // TODO: RandomPredicted and DropNextToPredicted
|
|
|
|
if (!_container.TryGetContainer(ent.Owner, StorageComponent.ContainerId, out var storageImplant))
|
|
return;
|
|
|
|
var contained = storageImplant.ContainedEntities.ToArray();
|
|
foreach (var entity in contained)
|
|
{
|
|
_transform.DropNextTo(entity, ent.Owner);
|
|
}
|
|
}
|
|
}
|