Files
wwdpublic/Content.Server/Silicon/EncryptionHolderRequiresLock/EncryptionHolderRequiresLockSystem.cs
VMSolidus 4a542df160 IPC Refactor (#771)
# Description

IPCs were ported from a codebase that didn't necessarily follow all of
our repo's coding standards. And while I had done my part to cleanup as
much of the system as was practical within the bounds of a Maintainer
Review, there were a lot of things that I felt were inappropriate to
leave to review, and wished to go over with a fine lense. Thus, here is
my Refactor of IPC code.

Do not merge this without first testing that nothing was broken. Because
I haven't tested it myself yet.
2024-10-19 12:57:44 +07:00

29 lines
934 B
C#

using Content.Shared.Lock;
using Content.Shared.Radio.Components;
using Content.Shared.Radio.EntitySystems;
namespace Content.Server.Silicon.EncryptionHolderRequiresLock;
public sealed class EncryptionHolderRequiresLockSystem : EntitySystem
{
[Dependency] private readonly EncryptionKeySystem _encryptionKeySystem = default!;
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EncryptionHolderRequiresLockComponent, LockToggledEvent>(LockToggled);
}
private void LockToggled(EntityUid uid, EncryptionHolderRequiresLockComponent component, LockToggledEvent args)
{
if (!TryComp<LockComponent>(uid, out var lockComp)
|| !TryComp<EncryptionKeyHolderComponent>(uid, out var keyHolder))
return;
keyHolder.KeysUnlocked = !lockComp.Locked;
_encryptionKeySystem.UpdateChannels(uid, keyHolder);
}
}