using Content.Shared.DeviceNetwork.Components;
namespace Content.Shared.DeviceNetwork.Systems;
///
public abstract class SharedDeviceNetworkJammerSystem : EntitySystem
{
///
/// Sets the range of the jamming effect.
///
public void SetRange(Entity ent, float value)
{
ent.Comp.Range = value;
Dirty(ent);
}
///
public bool TrySetRange(Entity ent, float value)
{
if (!Resolve(ent, ref ent.Comp, logMissing: false))
return false;
SetRange((ent, ent.Comp), value);
return true;
}
///
/// Returns the set of networks that this entity can jam.
public IReadOnlySet GetJammableNetworks(Entity ent)
{
return ent.Comp.JammableNetworks;
}
///
/// Enables this entity to jam packets on the specified network.
///
public void AddJammableNetwork(Entity ent, string networkId)
{
if (ent.Comp.JammableNetworks.Add(networkId))
Dirty(ent);
}
///
/// Stops this entity from jamming packets on the specified network.
///
public void RemoveJammableNetwork(Entity ent, string networkId)
{
if (ent.Comp.JammableNetworks.Remove(networkId))
Dirty(ent);
}
///
/// Stops this entity from jamming packets on any networks.
///
public void ClearJammableNetworks(Entity ent)
{
if (ent.Comp.JammableNetworks.Count == 0)
return;
ent.Comp.JammableNetworks.Clear();
Dirty(ent);
}
///
/// Enables this entity to stop packets with the specified frequency from being jammmed.
///
public void AddExcludedFrequency(Entity ent, uint frequency)
{
if (ent.Comp.FrequenciesExcluded.Add(frequency))
Dirty(ent);
}
///
/// Stops this entity to stop packets with the specified frequency from being jammmed.
///
public void RemoveExcludedFrequency(Entity ent, uint frequency)
{
if (ent.Comp.FrequenciesExcluded.Remove(frequency))
Dirty(ent);
}
///
/// Stops this entity to stop packets with any frequency from being jammmed.
///
public void ClearExcludedFrequency(Entity ent)
{
if (ent.Comp.FrequenciesExcluded.Count == 0)
return;
ent.Comp.FrequenciesExcluded.Clear();
Dirty(ent);
}
}