]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Xenoborg jammer now ignores xenoborg associated frequencies (#38005)
authorSamuka-C <47865393+Samuka-C@users.noreply.github.com>
Wed, 24 Sep 2025 22:02:46 +0000 (19:02 -0300)
committerGitHub <noreply@github.com>
Wed, 24 Sep 2025 22:02:46 +0000 (17:02 -0500)
* 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

Content.Server/DeviceNetwork/Systems/DeviceNetworkJammerSystem.cs
Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs
Content.Server/Radio/EntitySystems/JammerSystem.cs
Content.Shared/DeviceNetwork/Components/DeviceNetworkJammerComponent.cs
Content.Shared/DeviceNetwork/Events/BeforePacketSentEvent.cs
Content.Shared/DeviceNetwork/Systems/SharedDeviceNetworkJammerSystem.cs
Content.Shared/Radio/Components/ActiveRadioJammerComponent.cs
Content.Shared/Radio/Components/RadioJammerComponent.cs
Resources/Prototypes/Entities/Objects/Tools/jammer.yml

index 1905b752b837f33560fc3e9571dca233e31b4210..860ff886d440ac3f65e32c8f6d1237c28da923d3 100644 (file)
@@ -30,6 +30,10 @@ public sealed class DeviceNetworkJammerSystem : SharedDeviceNetworkJammerSystem
             if (!_jammer.GetJammableNetworks((uid, jammerComp)).Contains(ev.NetworkId))
                 continue;
 
+            if (jammerComp.FrequenciesExcluded != null &&
+                jammerComp.FrequenciesExcluded.Contains(ev.Frequency))
+                continue;
+
             if (_transform.InRange(jammerXform.Coordinates, ev.SenderTransform.Coordinates, jammerComp.Range)
                 || _transform.InRange(jammerXform.Coordinates, xform.Comp.Coordinates, jammerComp.Range))
             {
index 4b28fd9bf9cc1dc5f9df55dfc38a620e2be0790b..b2a648fc6357d17dd53a6121a920ed055a9c9f6f 100644 (file)
@@ -349,7 +349,7 @@ namespace Content.Server.DeviceNetwork.Systems
                 if (connection.Owner == packet.Sender)
                     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);
 
                 if (!beforeEv.Cancelled)
index 1cea981d3c8d086dd8c77d8eb893262c6f650a65..02c9c64c6ef16157df8ad53393305fd24c5f9370 100644 (file)
@@ -72,6 +72,15 @@ public sealed class JammerSystem : SharedJammerSystem
             EnsureComp<DeviceNetworkJammerComponent>(ent, out var jammingComp);
             _jammer.SetRange((ent, jammingComp), GetCurrentRange(ent));
             _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
         {
@@ -96,19 +105,23 @@ public sealed class JammerSystem : SharedJammerSystem
 
     private void OnRadioSendAttempt(ref RadioSendAttemptEvent args)
     {
-        if (ShouldCancelSend(args.RadioSource))
+        if (ShouldCancelSend(args.RadioSource, args.Channel.Frequency))
         {
             args.Cancelled = true;
         }
     }
 
-    private bool ShouldCancelSend(EntityUid sourceUid)
+    private bool ShouldCancelSend(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 != null && jam.FrequenciesExcluded.Contains(frequency))
+                continue;
+
             if (_transform.InRange(source, transform.Coordinates, GetCurrentRange((uid, jam))))
             {
                 return true;
index ab320d6d3e4b5bc15d296785b99ad7851b3061e3..5ee04de0d1a940fc3396ac78515598fd08a7cada 100644 (file)
@@ -23,4 +23,10 @@ public sealed partial class DeviceNetworkJammerComponent : Component
     [DataField, AutoNetworkedField]
     public HashSet<string> JammableNetworks = [];
 
+    /// <summary>
+    /// Device networks frequencies that wont be jammed.
+    /// </summary>
+    [DataField]
+    public HashSet<uint> FrequenciesExcluded = [];
+
 }
index 5d5c038dbf698b1749d7c85a9c1de0f69c88c088..b34995a285bf8c5887001d3bea082468b59a0a8d 100644 (file)
@@ -25,11 +25,17 @@ public sealed class BeforePacketSentEvent : CancellableEntityEventArgs
     /// </summary>
     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;
         SenderTransform = xform;
         SenderPosition = senderPosition;
         NetworkId = networkId;
+        Frequency = frequency;
     }
-}
\ No newline at end of file
+}
index fc714ea34f792637b75de42037b653f39ce079b3..6ed770ffbce271bd617aaadeb6168f11d5199528 100644 (file)
@@ -60,4 +60,34 @@ public abstract class SharedDeviceNetworkJammerSystem : EntitySystem
         ent.Comp.JammableNetworks.Clear();
         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);
+    }
 }
index d5679f118952de529e1a6c331d8bdaebb955c39b..87e4e0b3b3b5c2c8c507f90ea4235a9747e17a32 100644 (file)
@@ -4,7 +4,7 @@ using Robust.Shared.GameStates;
 namespace Content.Shared.Radio.Components;
 
 /// <summary>
-/// Prevents all radio in range from sending messages
+/// Prevents all non whitelisted radios from sending messages
 /// </summary>
 [RegisterComponent, NetworkedComponent]
 [Access(typeof(SharedJammerSystem))]
index 8f3519cf7d3ac9102230e5d180a47b78f297683d..af4f9e45c81d6e5ebef2746a94ba54ed884b30cb 100644 (file)
@@ -46,6 +46,12 @@ public sealed partial class RadioJammerComponent : Component
     [DataField(required: true), ViewVariables(VVAccess.ReadOnly)]
     public RadioJamSetting[] Settings;
 
+    /// <summary>
+    /// Frequencies that are NOT jammed by this jammer.
+    /// </summary>
+    [DataField]
+    public HashSet<int> FrequenciesExcluded = [];
+
     /// <summary>
     /// Index of the currently selected setting.
     /// </summary>
index 1fc42ad41fbeb660faeede33b9d5bf623c96bdd3..2922a3d53ee58a6be1042ad991e936d2d5face92 100644 (file)
   id: XenoborgRadioJammer
   name: xenoborg radio jammer
   components:
+  - type: RadioJammer
+    frequenciesExcluded:
+    - 2002 # xenoborg radio
+    - 2003 # mothership radio
+    - 2004 # xenoborg network
+    - 2005 # mothership network
   - type: ItemSlots
     slots:
       cell_slot: