mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-06-09 15:06:34 +02:00
71244bc140
* chore: move regions to partial classes * chore: forgot to remove the region
87 lines
3.4 KiB
C#
87 lines
3.4 KiB
C#
using Content.Shared.Chat;
|
|
using Content.Shared.Database;
|
|
using Content.Shared.Station.Components;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Server.Chat.Systems;
|
|
|
|
public sealed partial class ChatSystem
|
|
{
|
|
/// <inheritdoc />
|
|
public override void DispatchGlobalAnnouncement(
|
|
string message,
|
|
string? sender = null,
|
|
bool playSound = true,
|
|
SoundSpecifier? announcementSound = null,
|
|
Color? colorOverride = null
|
|
)
|
|
{
|
|
sender ??= Loc.GetString("chat-manager-sender-announcement");
|
|
|
|
var wrappedMessage = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender), ("message", FormattedMessage.EscapeText(message)));
|
|
_chatManager.ChatMessageToAll(ChatChannel.Radio, message, wrappedMessage, default, false, true, colorOverride);
|
|
if (playSound)
|
|
{
|
|
_audio.PlayGlobal(announcementSound ?? DefaultAnnouncementSound, Filter.Broadcast(), true, AudioParams.Default.WithVolume(-2f));
|
|
}
|
|
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Global station announcement from {sender}: {message}");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void DispatchFilteredAnnouncement(
|
|
Filter filter,
|
|
string message,
|
|
EntityUid? source = null,
|
|
string? sender = null,
|
|
bool playSound = true,
|
|
SoundSpecifier? announcementSound = null,
|
|
Color? colorOverride = null)
|
|
{
|
|
sender ??= Loc.GetString("chat-manager-sender-announcement");
|
|
|
|
var wrappedMessage = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender), ("message", FormattedMessage.EscapeText(message)));
|
|
_chatManager.ChatMessageToManyFiltered(filter, ChatChannel.Radio, message, wrappedMessage, source ?? default, false, true, colorOverride);
|
|
if (playSound)
|
|
{
|
|
_audio.PlayGlobal(announcementSound ?? DefaultAnnouncementSound, filter, true, AudioParams.Default.WithVolume(-2f));
|
|
}
|
|
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Station Announcement from {sender}: {message}");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void DispatchStationAnnouncement(
|
|
EntityUid source,
|
|
string message,
|
|
string? sender = null,
|
|
bool playDefaultSound = true,
|
|
SoundSpecifier? announcementSound = null,
|
|
Color? colorOverride = null)
|
|
{
|
|
sender ??= Loc.GetString("chat-manager-sender-announcement");
|
|
|
|
var wrappedMessage = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender), ("message", FormattedMessage.EscapeText(message)));
|
|
var station = _stationSystem.GetOwningStation(source);
|
|
|
|
if (station == null)
|
|
{
|
|
// you can't make a station announcement without a station
|
|
return;
|
|
}
|
|
|
|
if (!TryComp<StationDataComponent>(station, out var stationDataComp)) return;
|
|
|
|
var filter = _stationSystem.GetInStation(stationDataComp);
|
|
|
|
_chatManager.ChatMessageToManyFiltered(filter, ChatChannel.Radio, message, wrappedMessage, source, false, true, colorOverride);
|
|
|
|
if (playDefaultSound)
|
|
{
|
|
_audio.PlayGlobal(announcementSound ?? DefaultAnnouncementSound, filter, true, AudioParams.Default.WithVolume(-2f));
|
|
}
|
|
|
|
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Station Announcement on {station} from {sender}: {message}");
|
|
}
|
|
}
|