Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror: Make radio jammer block suit sensors #201

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Content.Server/Medical/SuitSensors/SuitSensorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,9 @@ public sealed partial class SuitSensorComponent : Component
[DataField, ViewVariables]
public bool PreviousControlsLocked = false;
}

[ByRefEvent]
public record struct SuitSensorsSendAttemptEvent
{
public bool Cancelled;
};
5 changes: 5 additions & 0 deletions Content.Server/Medical/SuitSensors/SuitSensorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public override void Update(float frameTime)
// TODO: This would cause imprecision at different tick rates.
sensor.NextUpdate = curTime + sensor.UpdateRate;

var canEv = new SuitSensorsSendAttemptEvent();
RaiseLocalEvent(uid, ref canEv);
if (canEv.Cancelled)
continue;

// get sensor status
var status = GetSensorState(uid, sensor);
if (status == null)
Expand Down
26 changes: 23 additions & 3 deletions Content.Server/Radio/EntitySystems/JammerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Medical.SuitSensors;
using Content.Server.Popups;
using Content.Server.Power.EntitySystems;
using Content.Server.PowerCell;
Expand All @@ -23,6 +24,7 @@ public override void Initialize()
SubscribeLocalEvent<ActiveRadioJammerComponent, PowerCellChangedEvent>(OnPowerCellChanged);
SubscribeLocalEvent<RadioJammerComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<RadioSendAttemptEvent>(OnRadioSendAttempt);
SubscribeLocalEvent<SuitSensorComponent, SuitSensorsSendAttemptEvent>(OnSensorSendAttempt);
}

public override void Update(float frameTime)
Expand Down Expand Up @@ -76,15 +78,33 @@ private void OnExamine(EntityUid uid, RadioJammerComponent comp, ExaminedEvent a

private void OnRadioSendAttempt(ref RadioSendAttemptEvent args)
{
var source = Transform(args.RadioSource).Coordinates;
if (ShouldCancelSend(args.RadioSource))
{
args.Cancelled = true;
}
}

private void OnSensorSendAttempt(EntityUid uid, SuitSensorComponent comp, ref SuitSensorsSendAttemptEvent args)
{
if (ShouldCancelSend(uid))
{
args.Cancelled = true;
}
}

private bool ShouldCancelSend(EntityUid sourceUid)
{
var source = Transform(sourceUid).Coordinates;
var query = EntityQueryEnumerator<ActiveRadioJammerComponent, RadioJammerComponent, TransformComponent>();

while (query.MoveNext(out _, out _, out var jam, out var transform))
{
if (source.InRange(EntityManager, _transform, transform.Coordinates, jam.Range))
{
args.Cancelled = true;
return;
return true;
}
}

return false;
}
}
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ uplink-clothing-eyes-hud-syndicate-name = Syndicate Visor
uplink-clothing-eyes-hud-syndicate-desc = The syndicate's professional head-up display, designed for better detection of humanoids and their subsequent elimination.

uplink-radio-jammer-name = Radio Jammer
uplink-radio-jammer-desc = This device will disrupt any nearby outgoing radio communication when activated.
uplink-radio-jammer-desc = This device will disrupt any nearby outgoing radio communication as well as suit sensors when activated.

uplink-syndicate-weapon-module-name = Weapon Cyborg Module
uplink-syndicate-weapon-module-desc = This module will give a cyborg advanced laser and machete
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Objects/Tools/jammer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: radio jammer
parent: BaseItem
id: RadioJammer
description: This device will disrupt any nearby outgoing radio communication when activated.
description: This device will disrupt any nearby outgoing radio communication as well as suit sensors when activated.
components:
- type: Sprite
sprite: Objects/Devices/jammer.rsi
Expand Down
Loading