Files
tbd-station-14/Content.Server/DeviceNetwork/Systems/DeviceNetworkJammerSystem.cs
Samuka-C ea3c44686c Xenoborg jammer now ignores xenoborg associated frequencies (#38005)
* stop jammer from jamming radio of certain frequency

* xenoborg jammer no longer jamms xenoborg radio

* stop jammer from jamming device network signals from certain frequency

* xenoborg jammer no longer jamms xenoborg camera signal

* the old tale of the missing ;

* backwards

* fix issue with readonly

* comments to the frequencies excluded

* triple typo

* clearer summary

* add summary

* fixed 4th hidden typo
2025-09-24 17:02:46 -05:00

47 lines
1.5 KiB
C#

using Content.Shared.DeviceNetwork.Components;
using Content.Shared.DeviceNetwork.Events;
using Content.Shared.DeviceNetwork.Systems;
using Robust.Server.GameObjects;
namespace Content.Server.DeviceNetwork.Systems;
/// <inheritdoc/>
public sealed class DeviceNetworkJammerSystem : SharedDeviceNetworkJammerSystem
{
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SharedDeviceNetworkJammerSystem _jammer = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TransformComponent, BeforePacketSentEvent>(BeforePacketSent);
}
private void BeforePacketSent(Entity<TransformComponent> xform, ref BeforePacketSentEvent ev)
{
if (ev.Cancelled)
return;
var query = EntityQueryEnumerator<DeviceNetworkJammerComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var jammerComp, out var jammerXform))
{
if (!_jammer.GetJammableNetworks((uid, jammerComp)).Contains(ev.NetworkId))
continue;
if (jammerComp.FrequenciesExcluded != null &&
jammerComp.FrequenciesExcluded.Contains(ev.Frequency))
continue;
if (_transform.InRange(jammerXform.Coordinates, ev.SenderTransform.Coordinates, jammerComp.Range)
|| _transform.InRange(jammerXform.Coordinates, xform.Comp.Coordinates, jammerComp.Range))
{
ev.Cancel();
return;
}
}
}
}