* 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>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Content.Server.Chat;
|
|
using Content.Server.Chat.Systems;
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.Actions.ActionTypes;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server.Actions
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class ActionsSystem : SharedActionsSystem
|
|
{
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ActionsComponent, PlayerAttachedEvent>(OnPlayerAttached);
|
|
SubscribeLocalEvent<ActionsComponent, ComponentStartup>(OnStartup);
|
|
SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<ActionsComponent, MetaFlagRemoveAttemptEvent>(OnMetaFlagRemoval);
|
|
}
|
|
|
|
private void OnMetaFlagRemoval(EntityUid uid, ActionsComponent component, ref MetaFlagRemoveAttemptEvent args)
|
|
{
|
|
if (component.LifeStage == ComponentLifeStage.Running)
|
|
args.ToRemove &= ~MetaDataFlags.EntitySpecific;
|
|
}
|
|
|
|
private void OnStartup(EntityUid uid, ActionsComponent component, ComponentStartup args)
|
|
{
|
|
_metaSystem.AddFlag(uid, MetaDataFlags.EntitySpecific);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args)
|
|
{
|
|
_metaSystem.RemoveFlag(uid, MetaDataFlags.EntitySpecific);
|
|
}
|
|
|
|
private void OnPlayerAttached(EntityUid uid, ActionsComponent component, PlayerAttachedEvent args)
|
|
{
|
|
// need to send state to new player.
|
|
Dirty(component);
|
|
}
|
|
|
|
protected override bool PerformBasicActions(EntityUid user, ActionType action)
|
|
{
|
|
var result = base.PerformBasicActions(user, action);
|
|
|
|
if (!string.IsNullOrWhiteSpace(action.Speech))
|
|
{
|
|
_chat.TrySendInGameICMessage(user, Loc.GetString(action.Speech), InGameICChatType.Speak, false);
|
|
result = true;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|