Add department-specific radio channels (#9061)
* Add department-specific radio channels
This commit adds working department-specific radio channels, while
minimizing damage to the current codebase. It is expected that a future
refactor will clean this up a bit.
ChatSystem now has a RadioPrefix() method that recognizes
department-specific channels (e.g. ":e" and ":m") in addition to the
global channel (";"). It strips the prefix from the message and assigns
messages an integer representing the destination channel, if any.
IListen and IRadio now accept optional 'channel' arguments with this
channel in mind.
The ugly is that the integer channel number is hard-coded and also shows
up in chat.
Comms are not modeled at this time. You cannot break comms (yet).
All headsets have channels soldered into them. You cannot change
encryption keys to hop on new channels. Steal a headset instead.
* Remove debugging print
* Convert to prototypes
* Use prototype names in headset prototype
* Adjust list style
* Document prototype fields
* cringe
* some cleanup
* colours
* Remove alphas at least
* cc
Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Content.Server.Radio.Components;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Radio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||
|
||||
namespace Content.Server.Ghost.Components
|
||||
{
|
||||
@@ -12,27 +14,27 @@ namespace Content.Server.Ghost.Components
|
||||
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
[DataField("channels")]
|
||||
private List<int> _channels = new(){1459};
|
||||
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||
private HashSet<string> _channels = new();
|
||||
|
||||
public IReadOnlyList<int> Channels => _channels;
|
||||
|
||||
public void Receive(string message, int channel, EntityUid speaker)
|
||||
public void Receive(string message, RadioChannelPrototype channel, EntityUid speaker)
|
||||
{
|
||||
if (!_entMan.TryGetComponent(Owner, out ActorComponent? actor))
|
||||
if (!_channels.Contains(channel.ID) || !_entMan.TryGetComponent(Owner, out ActorComponent? actor))
|
||||
return;
|
||||
|
||||
var playerChannel = actor.PlayerSession.ConnectedClient;
|
||||
|
||||
var msg = new MsgChatMessage();
|
||||
var msg = new MsgChatMessage
|
||||
{
|
||||
Channel = ChatChannel.Radio,
|
||||
Message = message,
|
||||
//Square brackets are added here to avoid issues with escaping
|
||||
MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"\\[{channel.Name}\\]"), ("name", _entMan.GetComponent<MetaDataComponent>(speaker).EntityName))
|
||||
};
|
||||
|
||||
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", _entMan.GetComponent<MetaDataComponent>(speaker).EntityName));
|
||||
_netManager.ServerSendMessage(msg, playerChannel);
|
||||
}
|
||||
|
||||
public void Broadcast(string message, EntityUid speaker) { }
|
||||
public void Broadcast(string message, EntityUid speaker, RadioChannelPrototype channel) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user