mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
* jaws of death * I hate YAML * open the gate * I forgot about this one * I forgor * Fix croissant * this didn't work actually rip * made lights look better and undo on the boxing gloves * small change * Update Resources/Prototypes/Entities/Clothing/Hands/gloves.yml Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> * baguette contraband, eat your evidence. * suffix --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com>
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using Content.Shared.DeviceNetwork.Components;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Power.EntitySystems;
|
|
using Content.Shared.PowerCell;
|
|
using Content.Shared.Radio.EntitySystems;
|
|
using Content.Shared.Radio.Components;
|
|
using Content.Shared.DeviceNetwork.Systems;
|
|
|
|
namespace Content.Server.Radio.EntitySystems;
|
|
|
|
public sealed class JammerSystem : SharedJammerSystem
|
|
{
|
|
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
|
[Dependency] private readonly SharedBatterySystem _battery = default!;
|
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
|
[Dependency] private readonly SharedDeviceNetworkJammerSystem _jammer = 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, int 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;
|
|
}
|
|
}
|