Add GhostRadio to allow ghosts to hear radio messages (#4896)
* Add GhostRadio to allow ghosts to hear radio messages * Add GhostRadio to ignored components
This commit is contained in:
@@ -284,7 +284,8 @@ namespace Content.Client.Entry
|
|||||||
"ToggleDoorOnTrigger",
|
"ToggleDoorOnTrigger",
|
||||||
"DeviceNetworkConnection",
|
"DeviceNetworkConnection",
|
||||||
"WiredNetworkConnection",
|
"WiredNetworkConnection",
|
||||||
"WirelessNetworkConnection"
|
"WirelessNetworkConnection",
|
||||||
|
"GhostRadio"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
45
Content.Server/Ghost/Components/GhostRadioComponent.cs
Normal file
45
Content.Server/Ghost/Components/GhostRadioComponent.cs
Normal file
@@ -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<int> _channels = new(){1459};
|
||||||
|
|
||||||
|
public IReadOnlyList<int> 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<MsgChatMessage>();
|
||||||
|
|
||||||
|
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) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,9 +9,10 @@
|
|||||||
context: "aghost"
|
context: "aghost"
|
||||||
- type: Ghost
|
- type: Ghost
|
||||||
canInteract: true
|
canInteract: true
|
||||||
|
- type: GhostRadio
|
||||||
- type: Hands
|
- type: Hands
|
||||||
- type: DoAfter
|
- type: DoAfter
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
- type: Actions
|
- type: Actions
|
||||||
innateActions:
|
innateActions:
|
||||||
- CombatMode
|
- CombatMode
|
||||||
|
|||||||
Reference in New Issue
Block a user