CatStation/Content.Server/Radio/EntitySystems/JammerSystem.cs
phönix da8bf6df00
Predict intercom examine. (#43107)
* radiosystem is funny

* review

Co-authored-by: slarticodefast <slarticodefast@users.noreply.github.com>
Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>

* dont forget your tests

* dont forget your loc

* networking

Co-authored-by: Tayrtahn <Tayrtahn@users.noreply.github.com>

* dont return because its breaks

* uh

* review

Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>

* more predictions and cleanup

* refactor: just me, being picky about whitespaces and commetns formatting

---------

Co-authored-by: slarticodefast <slarticodefast@users.noreply.github.com>
Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
Co-authored-by: Tayrtahn <Tayrtahn@users.noreply.github.com>
Co-authored-by: Tayrtahn <tayrtahn@gmail.com>
Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com>
Co-authored-by: Fildrance <fildrance@gmail.com>
2026-08-10 07:59:08 +00:00

51 lines
1.6 KiB
C#

using Content.Shared.Radio;
using Content.Shared.Radio.EntitySystems;
using Content.Shared.Radio.Components;
using Content.Shared.FixedPoint;
namespace Content.Server.Radio.EntitySystems;
public sealed partial class JammerSystem : SharedJammerSystem
{
[Dependency] private SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RadioSendAttemptEvent>(OnRadioSendAttempt);
SubscribeLocalEvent<RadioReceiveAttemptEvent>(OnRadioReceiveAttempt);
}
private void OnRadioSendAttempt(ref RadioSendAttemptEvent args)
{
if (ShouldCancel(args.RadioSource, args.Channel.Frequency))
args.Cancelled = true;
}
private void OnRadioReceiveAttempt(ref RadioReceiveAttemptEvent args)
{
if (ShouldCancel(args.RadioReceiver, args.Channel.Frequency))
args.Cancelled = true;
}
private bool ShouldCancel(EntityUid sourceUid, FixedPoint2 frequency)
{
var source = Transform(sourceUid).Coordinates;
var query = EntityQueryEnumerator<ActiveRadioJammerComponent, RadioJammerComponent, TransformComponent>();
while (query.MoveNext(out var uid, out _, out var jam, out var transform))
{
// Check if this jammer excludes the frequency
if (jam.FrequenciesExcluded.Contains(frequency))
continue;
if (_transform.InRange(source, transform.Coordinates, GetCurrentRange((uid, jam))))
{
return true;
}
}
return false;
}
}