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)
|
||||
|
||||
Reference in New Issue
Block a user