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
This commit is contained in:
@@ -30,6 +30,10 @@ public sealed class DeviceNetworkJammerSystem : SharedDeviceNetworkJammerSystem
|
|||||||
if (!_jammer.GetJammableNetworks((uid, jammerComp)).Contains(ev.NetworkId))
|
if (!_jammer.GetJammableNetworks((uid, jammerComp)).Contains(ev.NetworkId))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (jammerComp.FrequenciesExcluded != null &&
|
||||||
|
jammerComp.FrequenciesExcluded.Contains(ev.Frequency))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_transform.InRange(jammerXform.Coordinates, ev.SenderTransform.Coordinates, jammerComp.Range)
|
if (_transform.InRange(jammerXform.Coordinates, ev.SenderTransform.Coordinates, jammerComp.Range)
|
||||||
|| _transform.InRange(jammerXform.Coordinates, xform.Comp.Coordinates, jammerComp.Range))
|
|| _transform.InRange(jammerXform.Coordinates, xform.Comp.Coordinates, jammerComp.Range))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
|||||||
if (connection.Owner == packet.Sender)
|
if (connection.Owner == packet.Sender)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BeforePacketSentEvent beforeEv = new(packet.Sender, xform, senderPos, connection.NetIdEnum.ToString());
|
BeforePacketSentEvent beforeEv = new(packet.Sender, xform, senderPos, connection.NetIdEnum.ToString(), packet.Frequency);
|
||||||
RaiseLocalEvent(connection.Owner, beforeEv, false);
|
RaiseLocalEvent(connection.Owner, beforeEv, false);
|
||||||
|
|
||||||
if (!beforeEv.Cancelled)
|
if (!beforeEv.Cancelled)
|
||||||
|
|||||||
@@ -72,6 +72,15 @@ public sealed class JammerSystem : SharedJammerSystem
|
|||||||
EnsureComp<DeviceNetworkJammerComponent>(ent, out var jammingComp);
|
EnsureComp<DeviceNetworkJammerComponent>(ent, out var jammingComp);
|
||||||
_jammer.SetRange((ent, jammingComp), GetCurrentRange(ent));
|
_jammer.SetRange((ent, jammingComp), GetCurrentRange(ent));
|
||||||
_jammer.AddJammableNetwork((ent, jammingComp), DeviceNetworkComponent.DeviceNetIdDefaults.Wireless.ToString());
|
_jammer.AddJammableNetwork((ent, jammingComp), DeviceNetworkComponent.DeviceNetIdDefaults.Wireless.ToString());
|
||||||
|
|
||||||
|
// Add excluded frequencies using the system method
|
||||||
|
if (ent.Comp.FrequenciesExcluded != null)
|
||||||
|
{
|
||||||
|
foreach (var freq in ent.Comp.FrequenciesExcluded)
|
||||||
|
{
|
||||||
|
_jammer.AddExcludedFrequency((ent, jammingComp), (uint)freq);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -96,19 +105,23 @@ public sealed class JammerSystem : SharedJammerSystem
|
|||||||
|
|
||||||
private void OnRadioSendAttempt(ref RadioSendAttemptEvent args)
|
private void OnRadioSendAttempt(ref RadioSendAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (ShouldCancelSend(args.RadioSource))
|
if (ShouldCancelSend(args.RadioSource, args.Channel.Frequency))
|
||||||
{
|
{
|
||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldCancelSend(EntityUid sourceUid)
|
private bool ShouldCancelSend(EntityUid sourceUid, int frequency)
|
||||||
{
|
{
|
||||||
var source = Transform(sourceUid).Coordinates;
|
var source = Transform(sourceUid).Coordinates;
|
||||||
var query = EntityQueryEnumerator<ActiveRadioJammerComponent, RadioJammerComponent, TransformComponent>();
|
var query = EntityQueryEnumerator<ActiveRadioJammerComponent, RadioJammerComponent, TransformComponent>();
|
||||||
|
|
||||||
while (query.MoveNext(out var uid, out _, out var jam, out var transform))
|
while (query.MoveNext(out var uid, out _, out var jam, out var transform))
|
||||||
{
|
{
|
||||||
|
// Check if this jammer excludes the frequency
|
||||||
|
if (jam.FrequenciesExcluded != null && jam.FrequenciesExcluded.Contains(frequency))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (_transform.InRange(source, transform.Coordinates, GetCurrentRange((uid, jam))))
|
if (_transform.InRange(source, transform.Coordinates, GetCurrentRange((uid, jam))))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -23,4 +23,10 @@ public sealed partial class DeviceNetworkJammerComponent : Component
|
|||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public HashSet<string> JammableNetworks = [];
|
public HashSet<string> JammableNetworks = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Device networks frequencies that wont be jammed.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public HashSet<uint> FrequenciesExcluded = [];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,17 @@ public sealed class BeforePacketSentEvent : CancellableEntityEventArgs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly string NetworkId;
|
public readonly string NetworkId;
|
||||||
|
|
||||||
public BeforePacketSentEvent(EntityUid sender, TransformComponent xform, Vector2 senderPosition, string networkId)
|
/// <summary>
|
||||||
|
/// The frequency the packet is sent on.
|
||||||
|
/// </summary>
|
||||||
|
public readonly uint Frequency;
|
||||||
|
|
||||||
|
public BeforePacketSentEvent(EntityUid sender, TransformComponent xform, Vector2 senderPosition, string networkId, uint frequency)
|
||||||
{
|
{
|
||||||
Sender = sender;
|
Sender = sender;
|
||||||
SenderTransform = xform;
|
SenderTransform = xform;
|
||||||
SenderPosition = senderPosition;
|
SenderPosition = senderPosition;
|
||||||
NetworkId = networkId;
|
NetworkId = networkId;
|
||||||
|
Frequency = frequency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,4 +60,34 @@ public abstract class SharedDeviceNetworkJammerSystem : EntitySystem
|
|||||||
ent.Comp.JammableNetworks.Clear();
|
ent.Comp.JammableNetworks.Clear();
|
||||||
Dirty(ent);
|
Dirty(ent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables this entity to stop packets with the specified frequency from being jammmed.
|
||||||
|
/// </summary>
|
||||||
|
public void AddExcludedFrequency(Entity<DeviceNetworkJammerComponent> ent, uint frequency)
|
||||||
|
{
|
||||||
|
if (ent.Comp.FrequenciesExcluded.Add(frequency))
|
||||||
|
Dirty(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops this entity to stop packets with the specified frequency from being jammmed.
|
||||||
|
/// </summary>
|
||||||
|
public void RemoveExcludedFrequency(Entity<DeviceNetworkJammerComponent> ent, uint frequency)
|
||||||
|
{
|
||||||
|
if (ent.Comp.FrequenciesExcluded.Remove(frequency))
|
||||||
|
Dirty(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops this entity to stop packets with any frequency from being jammmed.
|
||||||
|
/// </summary>
|
||||||
|
public void ClearExcludedFrequency(Entity<DeviceNetworkJammerComponent> ent)
|
||||||
|
{
|
||||||
|
if (ent.Comp.FrequenciesExcluded.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ent.Comp.FrequenciesExcluded.Clear();
|
||||||
|
Dirty(ent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Robust.Shared.GameStates;
|
|||||||
namespace Content.Shared.Radio.Components;
|
namespace Content.Shared.Radio.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prevents all radio in range from sending messages
|
/// Prevents all non whitelisted radios from sending messages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
[Access(typeof(SharedJammerSystem))]
|
[Access(typeof(SharedJammerSystem))]
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ public sealed partial class RadioJammerComponent : Component
|
|||||||
[DataField(required: true), ViewVariables(VVAccess.ReadOnly)]
|
[DataField(required: true), ViewVariables(VVAccess.ReadOnly)]
|
||||||
public RadioJamSetting[] Settings;
|
public RadioJamSetting[] Settings;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Frequencies that are NOT jammed by this jammer.
|
||||||
|
/// </summary>
|
||||||
|
[DataField]
|
||||||
|
public HashSet<int> FrequenciesExcluded = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Index of the currently selected setting.
|
/// Index of the currently selected setting.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -56,6 +56,12 @@
|
|||||||
id: XenoborgRadioJammer
|
id: XenoborgRadioJammer
|
||||||
name: xenoborg radio jammer
|
name: xenoborg radio jammer
|
||||||
components:
|
components:
|
||||||
|
- type: RadioJammer
|
||||||
|
frequenciesExcluded:
|
||||||
|
- 2002 # xenoborg radio
|
||||||
|
- 2003 # mothership radio
|
||||||
|
- 2004 # xenoborg network
|
||||||
|
- 2005 # mothership network
|
||||||
- type: ItemSlots
|
- type: ItemSlots
|
||||||
slots:
|
slots:
|
||||||
cell_slot:
|
cell_slot:
|
||||||
|
|||||||
Reference in New Issue
Block a user