diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 4d710806f9..75f424ed44 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -284,7 +284,8 @@ namespace Content.Client.Entry "ToggleDoorOnTrigger", "DeviceNetworkConnection", "WiredNetworkConnection", - "WirelessNetworkConnection" + "WirelessNetworkConnection", + "GhostRadio" }; } } diff --git a/Content.Server/Ghost/Components/GhostRadioComponent.cs b/Content.Server/Ghost/Components/GhostRadioComponent.cs new file mode 100644 index 0000000000..7ce0d58b50 --- /dev/null +++ b/Content.Server/Ghost/Components/GhostRadioComponent.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using Content.Server.Radio.Components; +using Content.Shared.Chat; +using Robust.Server.GameObjects; +using Robust.Shared.Containers; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Network; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Ghost.Components +{ + [RegisterComponent] + [ComponentReference(typeof(IRadio))] + public class GhostRadioComponent : Component, IRadio + { + [Dependency] private readonly IServerNetManager _netManager = default!; + + public override string Name => "GhostRadio"; + + [DataField("channels")] + private List _channels = new(){1459}; + + public IReadOnlyList Channels => _channels; + + public void Receive(string message, int channel, IEntity speaker) + { + if (!Owner.TryGetComponent(out ActorComponent? actor)) + return; + + var playerChannel = actor.PlayerSession.ConnectedClient; + + var msg = _netManager.CreateNetMessage(); + + msg.Channel = ChatChannel.Radio; + msg.Message = message; + //Square brackets are added here to avoid issues with escaping + msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel}\\]"), ("name", speaker.Name)); + _netManager.ServerSendMessage(msg, playerChannel); + } + + public void Broadcast(string message, IEntity speaker) { } + } +} diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index 711d136468..54f7e01679 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -9,9 +9,10 @@ context: "aghost" - type: Ghost canInteract: true + - type: GhostRadio - type: Hands - type: DoAfter - - type: CombatMode + - type: CombatMode - type: Actions innateActions: - CombatMode