move all the radio components and system to Shared (#40293)
* move all the radio components and system to Shared. * duh split impl * address reviews * cleanup --------- Co-authored-by: walksanatora <walkerffo22@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Implants;
|
||||
using Content.Shared.Implants;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Shared.Radio.Components;
|
||||
|
||||
namespace Content.Server.Implants;
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component is required to receive radio message events.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class ActiveRadioComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The channels that this radio is listening on.
|
||||
/// </summary>
|
||||
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||
public HashSet<string> Channels = new();
|
||||
|
||||
/// <summary>
|
||||
/// A toggle for globally receiving all radio channels.
|
||||
/// Overrides <see cref="Channels"/>
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool ReceiveAllChannels;
|
||||
|
||||
/// <summary>
|
||||
/// If this radio can hear all messages on all maps
|
||||
/// </summary>
|
||||
[DataField("globalReceive")]
|
||||
public bool GlobalReceive = false;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component allows an entity to directly translate radio messages into chat messages. Note that this does not
|
||||
/// automatically add an <see cref="ActiveRadioComponent"/>, which is required to receive radio messages on specific
|
||||
/// channels.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class IntrinsicRadioReceiverComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component allows an entity to directly translate spoken text into radio messages (effectively an intrinsic
|
||||
/// radio headset).
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class IntrinsicRadioTransmitterComponent : Component
|
||||
{
|
||||
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||
public HashSet<string> Channels = new() { SharedChatSystem.CommonChannel };
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Listens for local chat messages and relays them to some radio frequency
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(RadioDeviceSystem))]
|
||||
public sealed partial class RadioMicrophoneComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("broadcastChannel", customTypeSerializer: typeof(PrototypeIdSerializer<RadioChannelPrototype>))]
|
||||
public string BroadcastChannel = SharedChatSystem.CommonChannel;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("listenRange")]
|
||||
public int ListenRange = 4;
|
||||
|
||||
[DataField("enabled")]
|
||||
public bool Enabled = false;
|
||||
|
||||
[DataField("powerRequired")]
|
||||
public bool PowerRequired = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not interacting with this entity
|
||||
/// toggles it on or off.
|
||||
/// </summary>
|
||||
[DataField("toggleOnInteract")]
|
||||
public bool ToggleOnInteract = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the speaker must have an
|
||||
/// unobstructed path to the radio to speak
|
||||
/// </summary>
|
||||
[DataField("unobstructedRequired")]
|
||||
public bool UnobstructedRequired = false;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Listens for radio messages and relays them to local chat.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(RadioDeviceSystem))]
|
||||
public sealed partial class RadioSpeakerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether or not interacting with this entity
|
||||
/// toggles it on or off.
|
||||
/// </summary>
|
||||
[DataField("toggleOnInteract")]
|
||||
public bool ToggleOnInteract = true;
|
||||
|
||||
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||
public HashSet<string> Channels = new () { SharedChatSystem.CommonChannel };
|
||||
|
||||
[DataField("enabled")]
|
||||
public bool Enabled;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
|
||||
namespace Content.Server.Radio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component is used to tag players that are currently wearing an ACTIVE headset.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class WearingHeadsetComponent : Component
|
||||
{
|
||||
[DataField("headset")]
|
||||
public EntityUid Headset;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Radio.Components;
|
||||
|
||||
@@ -3,7 +3,7 @@ using Content.Server.Chat.Systems;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Power;
|
||||
@@ -11,15 +11,15 @@ using Content.Shared.Radio;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.Radio.EntitySystems;
|
||||
|
||||
namespace Content.Server.Radio.EntitySystems;
|
||||
|
||||
/// <summary>
|
||||
/// This system handles radio speakers and microphones (which together form a hand-held radio).
|
||||
/// </summary>
|
||||
public sealed class RadioDeviceSystem : EntitySystem
|
||||
public sealed class RadioDeviceSystem : SharedRadioDeviceSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
@@ -100,15 +100,6 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
ToggleRadioSpeaker(uid, args.User, args.Handled, component);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
public void ToggleRadioMicrophone(EntityUid uid, EntityUid user, bool quiet = false, RadioMicrophoneComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
SetMicrophoneEnabled(uid, user, !component.Enabled, quiet, component);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, RadioMicrophoneComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
if (args.Powered)
|
||||
@@ -116,7 +107,8 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
SetMicrophoneEnabled(uid, null, false, true, component);
|
||||
}
|
||||
|
||||
public void SetMicrophoneEnabled(EntityUid uid, EntityUid? user, bool enabled, bool quiet = false, RadioMicrophoneComponent? component = null)
|
||||
|
||||
public override void SetMicrophoneEnabled(EntityUid uid, EntityUid? user, bool enabled, bool quiet = false, RadioMicrophoneComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
@@ -140,34 +132,6 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
RemCompDeferred<ActiveListenerComponent>(uid);
|
||||
}
|
||||
|
||||
public void ToggleRadioSpeaker(EntityUid uid, EntityUid user, bool quiet = false, RadioSpeakerComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
SetSpeakerEnabled(uid, user, !component.Enabled, quiet, component);
|
||||
}
|
||||
|
||||
public void SetSpeakerEnabled(EntityUid uid, EntityUid? user, bool enabled, bool quiet = false, RadioSpeakerComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.Enabled = enabled;
|
||||
|
||||
if (!quiet && user != null)
|
||||
{
|
||||
var state = Loc.GetString(component.Enabled ? "handheld-radio-component-on-state" : "handheld-radio-component-off-state");
|
||||
var message = Loc.GetString("handheld-radio-component-on-use", ("radioState", state));
|
||||
_popup.PopupEntity(message, user.Value, user.Value);
|
||||
}
|
||||
|
||||
_appearance.SetData(uid, RadioDeviceVisuals.Speaker, component.Enabled);
|
||||
if (component.Enabled)
|
||||
EnsureComp<ActiveRadioComponent>(uid).Channels.UnionWith(component.Channels);
|
||||
else
|
||||
RemCompDeferred<ActiveRadioComponent>(uid);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void OnExamine(EntityUid uid, RadioMicrophoneComponent component, ExaminedEvent args)
|
||||
@@ -277,9 +241,9 @@ public sealed class RadioDeviceSystem : EntitySystem
|
||||
}
|
||||
|
||||
if (TryComp<RadioMicrophoneComponent>(ent, out var mic))
|
||||
mic.BroadcastChannel = channel;
|
||||
mic.BroadcastChannel = channel.Value;
|
||||
if (TryComp<RadioSpeakerComponent>(ent, out var speaker))
|
||||
speaker.Channels = new() { channel };
|
||||
speaker.Channels = new() { channel.Value };
|
||||
Dirty(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Radio;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Inventory;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Chat;
|
||||
@@ -9,6 +8,7 @@ using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Roles.Components;
|
||||
using Content.Shared.Silicons.Laws;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Wires;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Speech;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Server.Vocalization.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.Radio.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -42,9 +42,9 @@ public sealed partial class RadioVocalizationSystem : EntitySystem
|
||||
/// Selects a random radio channel from all ActiveRadio entities in a given entity's inventory
|
||||
/// If no channels are found, this returns false and sets channel to an empty string
|
||||
/// </summary>
|
||||
private bool TryPickRandomRadioChannel(EntityUid entity, out string channel)
|
||||
private bool TryPickRandomRadioChannel(EntityUid entity, out ProtoId<RadioChannelPrototype> channel)
|
||||
{
|
||||
HashSet<string> potentialChannels = [];
|
||||
HashSet<ProtoId<RadioChannelPrototype>> potentialChannels = [];
|
||||
|
||||
// we don't have to check if this entity has an inventory. GetHandOrInventoryEntities will not yield anything
|
||||
// if an entity has no inventory or inventory slots
|
||||
|
||||
Reference in New Issue
Block a user