6
StarHorizon_Public/Content.Server/Radio/IntrinsicRadioKeySystem.cs
2026-01-24 12:49:55 +03:00

33 lines
1.1 KiB
C#

using Content.Server.Radio.Components;
using Content.Shared.Radio;
using Content.Shared.Radio.Components;
namespace Content.Server.Radio;
public sealed class IntrinsicRadioKeySystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IntrinsicRadioTransmitterComponent, EncryptionChannelsChangedEvent>(OnTransmitterChannelsChanged);
SubscribeLocalEvent<ActiveRadioComponent, EncryptionChannelsChangedEvent>(OnReceiverChannelsChanged);
}
private void OnTransmitterChannelsChanged(EntityUid uid, IntrinsicRadioTransmitterComponent component, EncryptionChannelsChangedEvent args)
{
UpdateChannels(uid, args.Component, ref component.Channels);
}
private void OnReceiverChannelsChanged(EntityUid uid, ActiveRadioComponent component, EncryptionChannelsChangedEvent args)
{
UpdateChannels(uid, args.Component, ref component.Channels);
}
private void UpdateChannels(EntityUid _, EncryptionKeyHolderComponent component, ref HashSet<string> channels)
{
channels.Clear();
channels.UnionWith(component.Channels);
}
}