mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* 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>
51 lines
1.6 KiB
C#
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;
|
|
}
|
|
}
|