Create DeviceNetworkJammerComponent & System as a general way for entities to act as jammers (#26342)
* Add DeviceNetworkJammerComponent & System Allows for entities to "jam" DeviceNetwork packets. Whenever a device attempts to send a packet, the DeviceNetworkJammerSystem listens for the BeforePacketSentEvent. From there if any entity with the jammer component is within range of either the sender or receiver of the packet the event will be cancelled. Additionally jammers can only block packets in certain networks. If a packet is not being transmitted in one of the networks it can block then even if the jammer is in range the event will not be cancelled. The range is stored in the jammer component along with the networks it can jam. Jammable network ids are stored as strings which seems to be how custom networks are stored (E.g. network ids for suit sensors). To allow for all of this, the BeforePacketSentEvent was modified to provide the NetworkId. * Make JammerSystem for the radio jammer use the DeviceNetworkJammer. Remove redundant event. * Replace calls to TryDistance with InRange
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Allow entities to jam DeviceNetwork packets.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class DeviceNetworkJammerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Range where packets will be jammed. This is checked both against the sender and receiver.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public float Range = 5.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Device networks that can be jammed. For a list of default NetworkIds see DeviceNetIdDefaults on Content.Server.
|
||||
/// Network ids are not guaranteed to be limited to DeviceNetIdDefaults.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public HashSet<string> JammableNetworks = [];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user