IPC paradox clone radio fix (#3545)

Fix is in
This commit is contained in:
beck-thompson 2025-04-21 14:09:47 -07:00 committed by GitHub
parent 950efccbd8
commit 7b7af6996e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
using Content.Server.Cloning;
using Content.Shared.Cloning.Events;
using Content.Shared.Radio.Components;
using Robust.Server.Containers;
namespace Content.Server._DV.Radio;
public sealed partial class EncryptionKeySystem : EntitySystem
{
[Dependency] private readonly CloningSystem _clone = default!;
[Dependency] private readonly ContainerSystem _container = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EncryptionKeyHolderComponent, CloningEvent>(OnClone);
}
// This is basically just for IPCs
public void OnClone(Entity<EncryptionKeyHolderComponent> keyHolder, ref CloningEvent args)
{
if (!args.Settings.CopyInternalStorage)
return;
if (!TryComp<EncryptionKeyHolderComponent>(args.CloneUid, out var clonesComp))
return;
var keys = keyHolder.Comp.KeyContainer.ContainedEntities;
foreach (var key in keys)
{
var spawned = _clone.CopyItem(key, Transform(keyHolder).Coordinates);
if (spawned != null)
_container.InsertOrDrop(spawned.Value, clonesComp.KeyContainer);
}
}
}