Communications Console: The ECSining (#8374)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -8,12 +8,15 @@ using Content.Server.Headset;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Inventory;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Network;
|
||||
@@ -41,9 +44,11 @@ public sealed class ChatSystem : SharedChatSystem
|
||||
[Dependency] private readonly ListeningSystem _listener = default!;
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
|
||||
private const int VoiceRange = 7; // how far voice goes in world units
|
||||
private const int WhisperRange = 2; // how far whisper goes in world units
|
||||
private const string AnnouncementSound = "/Audio/Announcements/announce.ogg";
|
||||
|
||||
private bool _loocEnabled = true;
|
||||
private readonly bool _adminLoocEnabled = true;
|
||||
@@ -140,6 +145,67 @@ public sealed class ChatSystem : SharedChatSystem
|
||||
}
|
||||
}
|
||||
|
||||
#region Announcements
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches an announcement to all stations
|
||||
/// </summary>
|
||||
/// <param name="message">The contents of the message</param>
|
||||
/// <param name="sender">The sender (Communications Console in Communications Console Announcement)</param>
|
||||
/// <param name="playDefaultSound">Play the announcement sound</param>
|
||||
/// <param name="colorOverride">Optional color for the announcement message</param>
|
||||
public void DispatchGlobalStationAnnouncement(string message, string sender = "Central Command",
|
||||
bool playDefaultSound = true, Color? colorOverride = null)
|
||||
{
|
||||
var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
||||
_chatManager.ChatMessageToAll(ChatChannel.Radio, message, messageWrap);
|
||||
if (playDefaultSound)
|
||||
{
|
||||
SoundSystem.Play(Filter.Broadcast(), AnnouncementSound, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Global station announcement from {sender}: {message}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispatches an announcement on a specific station
|
||||
/// </summary>
|
||||
/// <param name="source">The entity making the announcement (used to determine the station)</param>
|
||||
/// <param name="message">The contents of the message</param>
|
||||
/// <param name="sender">The sender (Communications Console in Communications Console Announcement)</param>
|
||||
/// <param name="playDefaultSound">Play the announcement sound</param>
|
||||
/// <param name="colorOverride">Optional color for the announcement message</param>
|
||||
public void DispatchStationAnnouncement(EntityUid source, string message, string sender = "Central Command", bool playDefaultSound = true, Color? colorOverride = null)
|
||||
{
|
||||
var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
||||
var station = _stationSystem.GetOwningStation(source);
|
||||
var filter = Filter.Empty();
|
||||
|
||||
if (station != null)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent<StationDataComponent>(station, out var stationDataComp)) return;
|
||||
|
||||
foreach (var gridEnt in stationDataComp.Grids)
|
||||
{
|
||||
filter.AddInGrid(gridEnt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filter = Filter.Pvs(source, entityManager: EntityManager);
|
||||
}
|
||||
|
||||
_chatManager.ChatMessageToManyFiltered(filter, ChatChannel.Radio, message, messageWrap, source, true, colorOverride);
|
||||
|
||||
if (playDefaultSound)
|
||||
{
|
||||
SoundSystem.Play(filter, AnnouncementSound, AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Station Announcement on {station} from {sender}: {message}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private API
|
||||
|
||||
private void SendEntitySpeak(EntityUid source, string message, bool hideChat = false)
|
||||
|
||||
@@ -3,13 +3,14 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.MoMMI;
|
||||
using Content.Server.Preferences.Managers;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -35,6 +36,10 @@ namespace Content.Server.Chat.Managers
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IServerPreferencesManager _preferencesManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
private StationSystem _stationSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum length a player-sent message can be sent
|
||||
@@ -46,6 +51,7 @@ namespace Content.Server.Chat.Managers
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_stationSystem = _entityManager.EntitySysManager.GetEntitySystem<StationSystem>();
|
||||
_netManager.RegisterNetMessage<MsgChatMessage>();
|
||||
|
||||
_configurationManager.OnValueChanged(CCVars.OocEnabled, OnOocEnabledChanged, true);
|
||||
@@ -79,18 +85,6 @@ namespace Content.Server.Chat.Managers
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Server announcement: {message}");
|
||||
}
|
||||
|
||||
public void DispatchStationAnnouncement(string message, string sender = "Central Command", bool playDefaultSound = true, Color? colorOverride = null)
|
||||
{
|
||||
var messageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender));
|
||||
ChatMessageToAll(ChatChannel.Radio, message, messageWrap, colorOverride);
|
||||
if (playDefaultSound)
|
||||
{
|
||||
SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f));
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Station Announcement from {sender}: {message}");
|
||||
}
|
||||
|
||||
public void DispatchServerMessage(IPlayerSession player, string message)
|
||||
{
|
||||
var messageWrap = Loc.GetString("chat-manager-server-wrap-message");
|
||||
@@ -235,6 +229,20 @@ namespace Content.Server.Chat.Managers
|
||||
_netManager.ServerSendToMany(msg, clients);
|
||||
}
|
||||
|
||||
public void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string messageWrap, EntityUid source,
|
||||
bool hideChat, Color? colorOverride = null)
|
||||
{
|
||||
if (!filter.Recipients.Any()) return;
|
||||
|
||||
var clients = new List<INetChannel>();
|
||||
foreach (var recipient in filter.Recipients)
|
||||
{
|
||||
clients.Add(recipient.ConnectedClient);
|
||||
}
|
||||
|
||||
ChatMessageToMany(channel, message, messageWrap, source, hideChat, clients);
|
||||
}
|
||||
|
||||
public void ChatMessageToAll(ChatChannel channel, string message, string messageWrap, Color? colorOverride = null)
|
||||
{
|
||||
var msg = new MsgChatMessage();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Chat;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.Chat.Managers
|
||||
{
|
||||
@@ -15,16 +16,6 @@ namespace Content.Server.Chat.Managers
|
||||
/// <param name="colorOverride">Override the color of the message being sent.</param>
|
||||
void DispatchServerAnnouncement(string message, Color? colorOverride = null);
|
||||
|
||||
/// <summary>
|
||||
/// Station announcement to every player
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="playDefaultSound">If the default 'PA' sound should be played.</param>
|
||||
/// <param name="colorOverride">Override the color of the message being sent.</param>
|
||||
void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true,
|
||||
Color? colorOverride = null);
|
||||
|
||||
void DispatchServerMessage(IPlayerSession player, string message);
|
||||
|
||||
void TrySendOOCMessage(IPlayerSession player, string message, OOCChatType type);
|
||||
@@ -36,6 +27,7 @@ namespace Content.Server.Chat.Managers
|
||||
INetChannel client);
|
||||
void ChatMessageToMany(ChatChannel channel, string message, string messageWrap, EntityUid source, bool hideChat,
|
||||
List<INetChannel> clients);
|
||||
void ChatMessageToManyFiltered(Filter filter, ChatChannel channel, string message, string messageWrap, EntityUid source, bool hideChat, Color? colorOverride);
|
||||
void ChatMessageToAll(ChatChannel channel, string message, string messageWrap, Color? colorOverride = null);
|
||||
|
||||
bool MessageCharacterLimit(IPlayerSession player, string message);
|
||||
|
||||
Reference in New Issue
Block a user