From 89ae3e81c9804562d2ed019e20da76042d31f0c0 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Fri, 7 Jun 2024 09:53:41 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=9E=D1=87=D0=B5=D1=80=D0=B5=D0=B4=D1=8C?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BE=D0=B7=D0=B2=D1=83=D1=87=D0=BA=D1=83=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=B2=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/_Sunrise/TTS/TTSSystem.cs | 72 ++++++++++++++----- Content.Server/AlertLevel/AlertLevelSystem.cs | 17 ++--- .../Bed/Cryostorage/CryostorageSystem.cs | 2 +- .../Chat/Systems/AnnounceOnSpawnSystem.cs | 2 +- Content.Server/Chat/Systems/ChatSystem.cs | 28 +++----- .../Communications/CommsHackerSystem.cs | 2 +- .../Systems/CriminalRecordsHackerSystem.cs | 2 +- Content.Server/Dragon/DragonRiftSystem.cs | 2 +- .../GameTicking/GameTicker.RoundFlow.cs | 2 +- .../GameTicking/GameTicker.Spawning.cs | 2 +- Content.Server/Nuke/NukeSystem.cs | 2 +- Content.Server/NukeOps/WarDeclaratorSystem.cs | 2 +- Content.Server/PowerSink/PowerSinkSystem.cs | 2 +- .../Systems/EmergencyShuttleSystem.Console.cs | 4 +- .../Systems/EmergencyShuttleSystem.cs | 10 +-- .../Events/RandomSentienceRule.cs | 2 +- .../Events/StationEventSystem.cs | 4 +- Content.Server/_Sunrise/TTS/TTSSystem.cs | 7 +- .../_Sunrise/TTS/AnnounceTTSEvent.cs | 4 +- 19 files changed, 97 insertions(+), 71 deletions(-) diff --git a/Content.Client/_Sunrise/TTS/TTSSystem.cs b/Content.Client/_Sunrise/TTS/TTSSystem.cs index c25cc059cbe..a37f402ce3f 100644 --- a/Content.Client/_Sunrise/TTS/TTSSystem.cs +++ b/Content.Client/_Sunrise/TTS/TTSSystem.cs @@ -3,6 +3,7 @@ using Robust.Client.Audio; using Robust.Client.ResourceManagement; using Robust.Shared.Audio; +using Robust.Shared.Audio.Components; using Robust.Shared.Audio.Systems; using Robust.Shared.Configuration; using Robust.Shared.ContentPack; @@ -25,9 +26,8 @@ public sealed class TTSSystem : EntitySystem private ISawmill _sawmill = default!; private readonly MemoryContentRoot _contentRoot = new(); private static readonly ResPath Prefix = ResPath.Root / "TTS"; - private static readonly AudioResource EmptyAudioResource = new(); - private const float TTSVolume = 0f; + private const float TtsVolume = 0f; private const float AnnounceVolume = 0f; private float _volume; @@ -36,6 +36,9 @@ public sealed class TTSSystem : EntitySystem private float _volumeAnnounce; private EntityUid _announcementUid = EntityUid.Invalid; + private Queue _announceQueue = new(); + private (EntityUid Entity, AudioComponent Component)? _currentPlaying; + public override void Initialize() { _sawmill = Logger.GetSawmill("tts"); @@ -83,12 +86,28 @@ private void OnAnnounceTTSPlay(AnnounceTtsEvent ev) if (_volumeAnnounce == 0) return; + _announceQueue.Enqueue(ev); + } + + private void PlayNextInQueue() + { + if (_announceQueue.Count == 0) + { + return; + } + + var ev = _announceQueue.Dequeue(); + if (_announcementUid == EntityUid.Invalid) _announcementUid = Spawn(null); - var finalParams = new AudioParams() {Volume = AnnounceVolume + SharedAudioSystem.GainToVolume(_volumeAnnounce)}; + var finalParams = new AudioParams() { Volume = AnnounceVolume + SharedAudioSystem.GainToVolume(_volumeAnnounce) }; - PlayTTSBytes(ev.Data, _announcementUid, finalParams, true); + if (ev.AnnouncementSound != null) + { + _currentPlaying = _audio.PlayGlobal(ev.AnnouncementSound, _announcementUid, finalParams.AddVolume(-5f)); + } + _currentPlaying = PlayTTSBytes(ev.Data, _announcementUid, finalParams, true); } private void OnTtsRadioVolumeChanged(float volume) @@ -103,18 +122,18 @@ private void OnPlayTTS(PlayTTSEvent ev) if (volume == 0) return; - volume = TTSVolume + SharedAudioSystem.GainToVolume(volume * ev.VolumeModifier); + volume = TtsVolume + SharedAudioSystem.GainToVolume(volume * ev.VolumeModifier); var audioParams = AudioParams.Default.WithVolume(volume); PlayTTSBytes(ev.Data, GetEntity(ev.SourceUid), audioParams); } - private void PlayTTSBytes(byte[] data, EntityUid? sourceUid = null, AudioParams? audioParams = null, bool globally = false) + private (EntityUid Entity, AudioComponent Component)? PlayTTSBytes(byte[] data, EntityUid? sourceUid = null, AudioParams? audioParams = null, bool globally = false) { _sawmill.Debug($"Play TTS audio {data.Length} bytes from {sourceUid} entity"); if (data.Length == 0) - return; + return null; var finalParams = audioParams ?? AudioParams.Default; @@ -125,27 +144,44 @@ private void PlayTTSBytes(byte[] data, EntityUid? sourceUid = null, AudioParams? res.Load(_dependencyCollection, Prefix / filePath); _resourceCache.CacheResource(Prefix / filePath, res); - if (sourceUid != null) - { - _audio.PlayEntity(res.AudioStream, sourceUid.Value, finalParams); - } - else - { - _audio.PlayGlobal(res.AudioStream, finalParams); - } + (EntityUid Entity, AudioComponent Component)? playing; if (globally) - _audio.PlayGlobal(res.AudioStream, finalParams); + { + playing = _audio.PlayGlobal(res.AudioStream, finalParams); + } else { if (sourceUid == null) - _audio.PlayGlobal(res.AudioStream, finalParams); + playing = _audio.PlayGlobal(res.AudioStream, finalParams); else - _audio.PlayEntity(res.AudioStream, sourceUid.Value, finalParams); + playing = _audio.PlayEntity(res.AudioStream, sourceUid.Value, finalParams); } _contentRoot.RemoveFile(filePath); _fileIdx++; + return playing; + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + + if (_currentPlaying.HasValue) + { + var (entity, component) = _currentPlaying.Value; + + if (Deleted(entity)) + { + _currentPlaying = null; + } + else + { + return; + } + } + + PlayNextInQueue(); } } diff --git a/Content.Server/AlertLevel/AlertLevelSystem.cs b/Content.Server/AlertLevel/AlertLevelSystem.cs index 1e57aa77f9b..613062fb10e 100644 --- a/Content.Server/AlertLevel/AlertLevelSystem.cs +++ b/Content.Server/AlertLevel/AlertLevelSystem.cs @@ -175,21 +175,18 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou var playDefault = false; if (playSound) { - if (detail.Sound != null) - { - var filter = _stationSystem.GetInOwningStation(station); - _audio.PlayGlobal(detail.Sound, filter, true, detail.Sound.Params); - } - else - { + if (detail.Sound == null) playDefault = true; - } } if (announce) { - _chatSystem.DispatchStationAnnouncement(station, announcementFull, playSound: playDefault, - colorOverride: detail.Color, sender: stationName); + _chatSystem.DispatchStationAnnouncement(station, + announcementFull, + announcementSound: detail.Sound, // Sunrise-edit, + playDefault: playDefault, + colorOverride: detail.Color, + sender: stationName); } RaiseLocalEvent(new AlertLevelChangedEvent(station, level)); diff --git a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs index 23ed6adc59e..7b7e21df6fa 100644 --- a/Content.Server/Bed/Cryostorage/CryostorageSystem.cs +++ b/Content.Server/Bed/Cryostorage/CryostorageSystem.cs @@ -241,7 +241,7 @@ public void HandleEnterCryostorage(Entity ent, Ne ("character", name), ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName)) ), Loc.GetString("earlyleave-cryo-sender"), - playSound: false + playDefault: false ); } diff --git a/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs b/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs index e52f39ad07f..ff114c93e14 100644 --- a/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs +++ b/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs @@ -17,6 +17,6 @@ private void OnInit(EntityUid uid, AnnounceOnSpawnComponent comp, MapInitEvent a { var message = Loc.GetString(comp.Message); var sender = comp.Sender != null ? Loc.GetString(comp.Sender) : "Central Command"; - _chat.DispatchGlobalAnnouncement(message, sender, playSound: true, announcementSound: comp.Sound, colorOverride: comp.Color); + _chat.DispatchGlobalAnnouncement(message, sender, playDefault: true, announcementSound: comp.Sound, colorOverride: comp.Color); } } diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 184203a5066..4aa1b9c4b2d 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -66,7 +66,6 @@ public sealed partial class ChatSystem : SharedChatSystem // public const int WhisperMuffledRange = 5; // how far whisper goes at all, in world units // Sunrise-TTS-End public const string DefaultAnnouncementSound = "/Audio/Announcements/announce.ogg"; // Sunrise-edit - public const string NukeAnnouncementSound = "/Audio/Announcements/war.ogg"; // Sunrise-edit private bool _loocEnabled = true; private bool _deadLoocEnabled; @@ -319,7 +318,7 @@ public void TrySendInGameOOCMessage( public void DispatchGlobalAnnouncement( string message, string sender = "Центральное коммандование", // Sunrise-edit - bool playSound = true, + bool playDefault = true, SoundSpecifier? announcementSound = null, bool playTts = true, // Sunrise-edit Color? colorOverride = null @@ -329,20 +328,15 @@ public void DispatchGlobalAnnouncement( _chatManager.ChatMessageToAll(ChatChannel.Radio, message, wrappedMessage, default, false, true, colorOverride); // Sunrise-start - if (playSound) + if (playDefault && announcementSound == null) { - if (sender == Loc.GetString("comms-console-announcement-title-nukie")) - { - announcementSound = new SoundPathSpecifier(NukeAnnouncementSound); // Sunrise-edit - } announcementSound ??= new SoundPathSpecifier(DefaultAnnouncementSound); - _audio.PlayGlobal(announcementSound?.GetSound() ?? DefaultAnnouncementSound, Filter.Broadcast(), true, announcementSound?.Params ?? AudioParams.Default.WithVolume(-2f)); } if (playTts) { var nukie = sender == Loc.GetString("comms-console-announcement-title-nukie"); - var announcementEv = new AnnouncementSpokeEvent(Filter.Broadcast(), message, nukie); + var announcementEv = new AnnouncementSpokeEvent(Filter.Broadcast(), message, announcementSound, nukie); RaiseLocalEvent(announcementEv); } // Sunrise-end @@ -364,9 +358,10 @@ public void DispatchStationAnnouncement( EntityUid source, string message, string sender = "Центральное коммандование", // Sunrise-edit - bool playSound = true, // Sunrise-edit + bool playDefault = true, // Sunrise-edit bool playTts = true,// Sunrise-edit - Color? colorOverride = null) + Color? colorOverride = null, + SoundSpecifier? announcementSound = null) { var wrappedMessage = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender), ("message", FormattedMessage.EscapeText(message))); var station = _stationSystem.GetOwningStation(source); @@ -384,15 +379,12 @@ public void DispatchStationAnnouncement( _chatManager.ChatMessageToManyFiltered(filter, ChatChannel.Radio, message, wrappedMessage, source, false, true, colorOverride); // Sunrise-start - if (playSound) - { - var announcementSound = new SoundPathSpecifier(DefaultAnnouncementSound); - _audio.PlayGlobal(announcementSound?.GetSound() ?? DefaultAnnouncementSound, Filter.Broadcast(), true, announcementSound?.Params ?? AudioParams.Default.WithVolume(-2f)); - } + if (playDefault && announcementSound == null) + announcementSound = new SoundPathSpecifier(DefaultAnnouncementSound); if (playTts) { - RaiseLocalEvent(new AnnouncementSpokeEvent(filter, message)); + RaiseLocalEvent(new AnnouncementSpokeEvent(filter, message, announcementSound)); } // Sunrise-edit @@ -1013,12 +1005,14 @@ public enum ChatTransmitRange : byte public sealed class AnnouncementSpokeEvent( Filter source, string message, + SoundSpecifier? announcementSound, bool nukie = false) : EntityEventArgs { public readonly Filter Source = source; public readonly string Message = message; public readonly bool Nukie = nukie; + public readonly SoundSpecifier? AnnouncementSound = announcementSound; } public sealed class RadioSpokeEvent(EntityUid source, string message, EntityUid[] receivers) : EntityEventArgs diff --git a/Content.Server/Communications/CommsHackerSystem.cs b/Content.Server/Communications/CommsHackerSystem.cs index 13587d1769e..2b2ccf81f89 100644 --- a/Content.Server/Communications/CommsHackerSystem.cs +++ b/Content.Server/Communications/CommsHackerSystem.cs @@ -79,7 +79,7 @@ private void OnDoAfter(EntityUid uid, CommsHackerComponent comp, TerrorDoAfterEv public void CallInThreat(NinjaHackingThreatPrototype ninjaHackingThreat) { _gameTicker.StartGameRule(ninjaHackingThreat.Rule, out _); - _chat.DispatchGlobalAnnouncement(Loc.GetString(ninjaHackingThreat.Announcement), playSound: true, playTts: true, colorOverride: Color.Red); + _chat.DispatchGlobalAnnouncement(Loc.GetString(ninjaHackingThreat.Announcement), playDefault: true, playTts: true, colorOverride: Color.Red); } } diff --git a/Content.Server/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs b/Content.Server/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs index b0181a0adc0..5db21ecd357 100644 --- a/Content.Server/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs +++ b/Content.Server/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs @@ -46,7 +46,7 @@ private void OnDoAfter(Entity ent, ref CriminalR // main damage with this is existing arrest warrants are lost and to anger beepsky } - _chat.DispatchGlobalAnnouncement(Loc.GetString(ent.Comp.Announcement), playSound: true, colorOverride: Color.Red); + _chat.DispatchGlobalAnnouncement(Loc.GetString(ent.Comp.Announcement), playDefault: true, colorOverride: Color.Red); // once is enough RemComp(ent); diff --git a/Content.Server/Dragon/DragonRiftSystem.cs b/Content.Server/Dragon/DragonRiftSystem.cs index 2bee41801f6..05753b5daed 100644 --- a/Content.Server/Dragon/DragonRiftSystem.cs +++ b/Content.Server/Dragon/DragonRiftSystem.cs @@ -72,7 +72,7 @@ public override void Update(float frameTime) var msg = Loc.GetString("carp-rift-warning", ("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, xform))))); - _chat.DispatchGlobalAnnouncement(msg, playSound: false, playTts: true, colorOverride: Color.Red); + _chat.DispatchGlobalAnnouncement(msg, playDefault: false, playTts: true, colorOverride: Color.Red); _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); _navMap.SetBeaconEnabled(uid, true); } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 72e0e4bc536..5a3e7b44361 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -637,7 +637,7 @@ private void AnnounceRound() var proto = _robustRandom.Pick(options); if (proto.Message != null) - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true, playTts: false); + _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playDefault: true, playTts: false); if (proto.Sound != null) _audio.PlayGlobal(proto.Sound, Filter.Broadcast(), true); diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index f89805ebc5e..bcec75c8956 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -248,7 +248,7 @@ private void SpawnPlayer(ICommonSession player, ("gender", character.Gender), // Russian-LastnameGender ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName))), Loc.GetString("latejoin-arrival-sender"), - playSound: false); + playDefault: false); } if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}")) diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 5b9bb295990..549d3f7f2b9 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -463,7 +463,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null) ("time", (int) component.RemainingTime), ("location", FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((uid, nukeXform))))); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, playSound: false, colorOverride: Color.Red); + _chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, playDefault: false, colorOverride: Color.Red); _sound.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound)); _nukeSongLength = (float) _audio.GetAudioLength(_selectedNukeSong).TotalSeconds; diff --git a/Content.Server/NukeOps/WarDeclaratorSystem.cs b/Content.Server/NukeOps/WarDeclaratorSystem.cs index 4ffa039bac9..fccef341234 100644 --- a/Content.Server/NukeOps/WarDeclaratorSystem.cs +++ b/Content.Server/NukeOps/WarDeclaratorSystem.cs @@ -71,7 +71,7 @@ private void OnActivated(Entity ent, ref WarDeclaratorAc if (ev.Status == WarConditionStatus.WarReady) { var title = Loc.GetString(ent.Comp.SenderTitle); - _chat.DispatchGlobalAnnouncement(ent.Comp.Message, title, playSound: true, ent.Comp.Sound, colorOverride: ent.Comp.Color); + _chat.DispatchGlobalAnnouncement(ent.Comp.Message, title, playDefault: true, ent.Comp.Sound, colorOverride: ent.Comp.Color); _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(args.Actor):player} has declared war with this text: {ent.Comp.Message}"); } diff --git a/Content.Server/PowerSink/PowerSinkSystem.cs b/Content.Server/PowerSink/PowerSinkSystem.cs index 635d271af9b..1083946e98f 100644 --- a/Content.Server/PowerSink/PowerSinkSystem.cs +++ b/Content.Server/PowerSink/PowerSinkSystem.cs @@ -129,7 +129,7 @@ private void NotifyStationOfImminentExplosion(EntityUid uid, PowerSinkComponent _chat.DispatchStationAnnouncement( station.Value, Loc.GetString("powersink-immiment-explosion-announcement"), - playSound: true, + playDefault: true, colorOverride: Color.Yellow ); } diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index 4790c351e85..1a99a2494a4 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -314,7 +314,7 @@ private void OnEmergencyAuthorize(EntityUid uid, EmergencyShuttleConsoleComponen if (remaining > 0) _chatSystem.DispatchGlobalAnnouncement( Loc.GetString("emergency-shuttle-console-auth-left", ("remaining", remaining)), - playSound: false, colorOverride: DangerColor); + playDefault: false, colorOverride: DangerColor); if (!CheckForLaunch(component)) _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true); @@ -418,7 +418,7 @@ private void AnnounceLaunch() _announced = true; _chatSystem.DispatchGlobalAnnouncement( Loc.GetString("emergency-shuttle-launch-time", ("consoleAccumulator", $"{_consoleAccumulator:0}")), - playSound: false, + playDefault: false, colorOverride: DangerColor); _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true); diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 25bb84570d2..12e06d70885 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -38,6 +38,7 @@ using Robust.Shared.Timing; using Robust.Shared.Utility; using Content.Server.GameTicking; +using Robust.Shared.Audio; namespace Content.Server.Shuttles.Systems; @@ -283,6 +284,7 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo } var targetGrid = _station.GetLargestGrid(Comp(stationUid)); + var announcementSound = new SoundPathSpecifier("/Audio/Misc/notice1.ogg"); // Sunrise-start DockTime = _timing.CurTime; @@ -292,9 +294,8 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo if (targetGrid == null) { _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to dock with station {ToPrettyString(stationUid)}"); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-good-luck"), playSound: false); + _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-good-luck"), announcementSound: announcementSound); // Sunrise-edit // TODO: Need filter extensions or something don't blame me. - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); return; } @@ -307,7 +308,7 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); var direction = ContentLocalizationManager.FormatDirection(angle.GetDir()); var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform))); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playSound: false); + _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playDefault: false); } // shuttle timers @@ -336,12 +337,11 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); var direction = ContentLocalizationManager.FormatDirection(angle.GetDir()); var location = FormattedMessage.RemoveMarkup(_navMap.GetNearestBeaconString((stationShuttle.EmergencyShuttle.Value, xform))); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), playSound: false); + _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("time", $"{_consoleAccumulator:0}"), ("direction", direction), ("location", location)), announcementSound: announcementSound); // Sunrise-Edit } _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to find a valid docking port for {ToPrettyString(stationUid)}"); // TODO: Need filter extensions or something don't blame me. - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); } } diff --git a/Content.Server/StationEvents/Events/RandomSentienceRule.cs b/Content.Server/StationEvents/Events/RandomSentienceRule.cs index 8676c07d3b1..3027aa105b4 100644 --- a/Content.Server/StationEvents/Events/RandomSentienceRule.cs +++ b/Content.Server/StationEvents/Events/RandomSentienceRule.cs @@ -60,7 +60,7 @@ protected override void Started(EntityUid uid, RandomSentienceRuleComponent comp ("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count), ("data", Loc.GetString($"random-sentience-event-data-{RobustRandom.Next(1, 6)}")), ("strength", Loc.GetString($"random-sentience-event-strength-{RobustRandom.Next(1, 8)}"))), - playSound: false, + playDefault: false, colorOverride: Color.Gold ); } diff --git a/Content.Server/StationEvents/Events/StationEventSystem.cs b/Content.Server/StationEvents/Events/StationEventSystem.cs index c4c51afd2a1..3c80e8b8c3f 100644 --- a/Content.Server/StationEvents/Events/StationEventSystem.cs +++ b/Content.Server/StationEvents/Events/StationEventSystem.cs @@ -42,7 +42,7 @@ protected override void Added(EntityUid uid, T component, GameRuleComponent game AdminLogManager.Add(LogType.EventAnnounced, $"Event added / announced: {ToPrettyString(uid)}"); if (stationEvent.StartAnnouncement != null) - ChatSystem.DispatchGlobalAnnouncement(Loc.GetString(stationEvent.StartAnnouncement), playSound: false, colorOverride: stationEvent.StartAnnouncementColor); + ChatSystem.DispatchGlobalAnnouncement(Loc.GetString(stationEvent.StartAnnouncement), playDefault: false, colorOverride: stationEvent.StartAnnouncementColor); Audio.PlayGlobal(stationEvent.StartAudio, Filter.Broadcast(), true); } @@ -78,7 +78,7 @@ protected override void Ended(EntityUid uid, T component, GameRuleComponent game AdminLogManager.Add(LogType.EventStopped, $"Event ended: {ToPrettyString(uid)}"); if (stationEvent.EndAnnouncement != null) - ChatSystem.DispatchGlobalAnnouncement(Loc.GetString(stationEvent.EndAnnouncement), playSound: false, colorOverride: stationEvent.EndAnnouncementColor); + ChatSystem.DispatchGlobalAnnouncement(Loc.GetString(stationEvent.EndAnnouncement), playDefault: false, colorOverride: stationEvent.EndAnnouncementColor); Audio.PlayGlobal(stationEvent.EndAudio, Filter.Broadcast(), true); } diff --git a/Content.Server/_Sunrise/TTS/TTSSystem.cs b/Content.Server/_Sunrise/TTS/TTSSystem.cs index 0d8568c7676..e6881bf2c34 100644 --- a/Content.Server/_Sunrise/TTS/TTSSystem.cs +++ b/Content.Server/_Sunrise/TTS/TTSSystem.cs @@ -121,14 +121,11 @@ private async void OnAnnouncementSpoke(AnnouncementSpokeEvent args) if (!_isEnabled || args.Message.Length > MaxMessageChars * 2 || !GetVoicePrototype(args.Nukie ? _nukieVoiceId : _voiceId, out var protoVoice)) - { - RaiseNetworkEvent(new AnnounceTtsEvent(new byte[] { }), args.Source.RemovePlayers(_ignoredRecipients)); return; - } var soundData = await GenerateTTS(args.Message, protoVoice.Speaker, isAnnounce: true); - soundData ??= new byte[] { }; - RaiseNetworkEvent(new AnnounceTtsEvent(soundData), args.Source.RemovePlayers(_ignoredRecipients)); + soundData ??= []; + RaiseNetworkEvent(new AnnounceTtsEvent(soundData, args.AnnouncementSound), args.Source.RemovePlayers(_ignoredRecipients)); } private async void OnEntitySpoke(EntityUid uid, TTSComponent component, EntitySpokeEvent args) diff --git a/Content.Shared/_Sunrise/TTS/AnnounceTTSEvent.cs b/Content.Shared/_Sunrise/TTS/AnnounceTTSEvent.cs index e4292fdce35..286ebff2046 100644 --- a/Content.Shared/_Sunrise/TTS/AnnounceTTSEvent.cs +++ b/Content.Shared/_Sunrise/TTS/AnnounceTTSEvent.cs @@ -1,10 +1,12 @@ +using Robust.Shared.Audio; using Robust.Shared.Serialization; namespace Content.Shared._Sunrise.TTS; [Serializable, NetSerializable] -public sealed class AnnounceTtsEvent(byte[] data) +public sealed class AnnounceTtsEvent(byte[] data, SoundSpecifier? announcementSound) : EntityEventArgs { public byte[] Data { get; } = data; + public SoundSpecifier? AnnouncementSound = announcementSound; } From 08e862dd12888f0c891a26c20d94dbf52a55c3f0 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Fri, 7 Jun 2024 10:58:49 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=20=D0=B8=20=D0=BE=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=82=D1=82=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/_Sunrise/TTS/TTSSystem.cs | 15 +++++++++------ Content.Server/_Sunrise/TTS/TTSSystem.cs | 16 ++++++++++++++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Content.Client/_Sunrise/TTS/TTSSystem.cs b/Content.Client/_Sunrise/TTS/TTSSystem.cs index a37f402ce3f..2a1890193d2 100644 --- a/Content.Client/_Sunrise/TTS/TTSSystem.cs +++ b/Content.Client/_Sunrise/TTS/TTSSystem.cs @@ -126,15 +126,21 @@ private void OnPlayTTS(PlayTTSEvent ev) var audioParams = AudioParams.Default.WithVolume(volume); - PlayTTSBytes(ev.Data, GetEntity(ev.SourceUid), audioParams); + var entity = GetEntity(ev.SourceUid); + PlayTTSBytes(ev.Data, entity, audioParams); } private (EntityUid Entity, AudioComponent Component)? PlayTTSBytes(byte[] data, EntityUid? sourceUid = null, AudioParams? audioParams = null, bool globally = false) { - _sawmill.Debug($"Play TTS audio {data.Length} bytes from {sourceUid} entity"); if (data.Length == 0) return null; + // если sourceUid.Value.Id == 0 то значит эта сущность не прогружена на стороне клиента + if ((sourceUid == null || sourceUid.Value.Id == 0) && !globally) + return null; + + _sawmill.Debug($"Play TTS audio {data.Length} bytes from {sourceUid} entity"); + var finalParams = audioParams ?? AudioParams.Default; var filePath = new ResPath($"{_fileIdx}.ogg"); @@ -152,10 +158,7 @@ private void OnPlayTTS(PlayTTSEvent ev) } else { - if (sourceUid == null) - playing = _audio.PlayGlobal(res.AudioStream, finalParams); - else - playing = _audio.PlayEntity(res.AudioStream, sourceUid.Value, finalParams); + playing = sourceUid == null ? null : _audio.PlayEntity(res.AudioStream, sourceUid.Value, finalParams); } _contentRoot.RemoveFile(filePath); diff --git a/Content.Server/_Sunrise/TTS/TTSSystem.cs b/Content.Server/_Sunrise/TTS/TTSSystem.cs index e6881bf2c34..5d1dd924839 100644 --- a/Content.Server/_Sunrise/TTS/TTSSystem.cs +++ b/Content.Server/_Sunrise/TTS/TTSSystem.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Threading.Tasks; using Content.Server.Chat.Systems; using Content.Shared._Sunrise.SunriseCCVars; @@ -156,9 +157,20 @@ private async void OnEntitySpoke(EntityUid uid, TTSComponent component, EntitySp private async void HandleSay(EntityUid uid, string message, string speaker) { + var recipients = Filter.Pvs(uid, 1F).RemovePlayers(_ignoredRecipients); + + // Если нету получаетей ттса то зачем вообще генерировать его? + if (!recipients.Recipients.Any()) + return; + var soundData = await GenerateTTS(message, speaker); - if (soundData is null) return; - RaiseNetworkEvent(new PlayTTSEvent(soundData, GetNetEntity(uid)), Filter.Pvs(uid).RemovePlayers(_ignoredRecipients)); + + if (soundData is null) + return; + + var netEntity = GetNetEntity(uid); + + RaiseNetworkEvent(new PlayTTSEvent(soundData, netEntity), recipients); } private async void HandleWhisper(EntityUid uid, string message, string speaker, bool isRadio) From a0db650a4aef0ae3ae991cee30304798e2441a89 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Fri, 7 Jun 2024 10:59:01 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A3=D0=BA=D0=BE=D1=80=D0=BE=D1=82=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Locale/ru-RU/alert-levels/alert-levels.ftl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/Locale/ru-RU/alert-levels/alert-levels.ftl b/Resources/Locale/ru-RU/alert-levels/alert-levels.ftl index 0fc191526ef..14f78a8ac70 100644 --- a/Resources/Locale/ru-RU/alert-levels/alert-levels.ftl +++ b/Resources/Locale/ru-RU/alert-levels/alert-levels.ftl @@ -5,19 +5,19 @@ alert-level-green = Зелёный alert-level-green-announcement = Можно безопасно возвращаться на свои рабочие места. alert-level-green-instructions = Выполняйте свою работу. alert-level-blue = Синий -alert-level-blue-announcement = На станции присутствует неизвестная угроза. Службе безопасности разрешено проводить выборочные обыски. Членам экипажа рекомендуется выполнять указания, отдаваемые действующей властью. Для ускорения процедур, просим сотрудников проверить наличие ID-карт в своих КПК. +alert-level-blue-announcement = На станции присутствует неизвестная угроза. Службе безопасности разрешено проводить выборочные обыски. Для ускорения процедур, просим сотрудников проверить наличие ID-карт в своих КПК. alert-level-blue-instructions = Каждый сотрудник обязан носить свою ID-карту в своём КПК. Также членам экипажа рекомендуется проявлять бдительность и сообщать службе безопасности o любой подозрительной активности. alert-level-red = Красный -alert-level-red-announcement = На станции присутствует известная угроза. Служба безопасности имеет право применять летальную силу по необходимости. Все члены экипажа, за исключением должностных лиц, обязаны проследовать в свои отделы и ожидать дальнейших инструкций до отмены кода. Нарушители подлежат наказанию. +alert-level-red-announcement = На станции присутствует известная угроза. Служба безопасности имеет право применять летальную силу по необходимости. Все члены экипажа, за исключением должностных лиц, обязаны проследовать в свои отделы и ожидать дальнейших инструкций до отмены кода. alert-level-red-instructions = Экипаж обязан подчиняться правомерным приказам сотрудников Службы Безопасности. Переключите режим работы своего костюма в режим "Координаты" и находитесь в своём отделе. alert-level-violet = Фиолетовый -alert-level-violet-announcement = На станции присутствует угроза вируса. Медицинскому персоналу необходимо изолировать членов экипажа с любыми симптомами. Членам экипажа рекомендуется дистанцироваться друг от друга и соблюдать меры безопасности по предотвращению дальнейшего распространения вируса, следовать иным указаниям Главного Врача смены. На время действия Фиолетового Кода любые стыковки станции с другими объектами категорически запрещены. Сотрудники Службы Безопасности продолжают выполнение своих обязанностей по предыдущему коду. +alert-level-violet-announcement = На станции присутствует угроза вируса. Членам экипажа рекомендуется держать дистанцию между собой и соблюдать меры безопасности по предотвращению дальнейшего распространения вируса. alert-level-violet-instructions = Членам экипажа рекомендуется держать дистанцию между собой и соблюдать меры безопасности по предотвращению дальнейшего распространения вируса. Если вы чувствуете себя плохо - вам следует незамедлительно пройти на обследование, надев заранее стерильную маску. alert-level-yellow = Жёлтый -alert-level-yellow-announcement = На станции присутствует структурная или атмосферная угроза. Инженерно-техническому персоналу требуется немедленно предпринять меры по устранению угрозы. Всем остальным сотрудникам запрещено находиться в опасном участке. Сотрудники Службы Безопасности продолжают выполнение своих обязанностей по предыдущему коду. +alert-level-yellow-announcement = На станции присутствует структурная или атмосферная угроза. Инженерно-техническому персоналу требуется немедленно предпринять меры по устранению угрозы. Всем остальным сотрудникам запрещено находиться в опасном участке. alert-level-yellow-instructions = Членам экипажа необходимо в срочном порядке покинуть опасную зону и, по возможности, оставаться на своих рабочих местах. alert-level-gamma = Гамма -alert-level-gamma-announcement = Центральное командование объявило на станции уровень угрозы "Гамма". Служба безопасности должна постоянно иметь при себе оружие, гражданский персонал обязан немедленно обратиться к главам отделов для получения указаний к эвакуации. Службе Безопасности разрешено применение летальной силы в случае неповиновения. +alert-level-gamma-announcement = Центральное командование объявило на станции уровень угрозы "Гамма". Служба безопасности должна постоянно иметь при себе оружие, гражданский персонал обязан немедленно обратиться к главам отделов для получения указаний к эвакуации. alert-level-gamma-instructions = Гражданский персонал обязан немедленно обратиться к главам отделов для получения указаний к эвакуации. Корпорация Nanotrasen заверяет вас - опасность скоро будет нейтрализована. alert-level-delta = Дельта alert-level-delta-announcement = Станция находится под угрозой неминуемого уничтожения. Членам экипажа рекомендуется слушать глав отделов для получения дополнительной информации. Службе Безопасности приказано работать по протоколу Дельта. From 62b9066bb051e136a98656214dbf385e0a0553fe Mon Sep 17 00:00:00 2001 From: VigersRay Date: Fri, 7 Jun 2024 11:01:16 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D1=87=D0=B5=D0=B9=D0=BD=D0=B6=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Changelog/ChangelogSunrise.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Resources/Changelog/ChangelogSunrise.yml b/Resources/Changelog/ChangelogSunrise.yml index d59b61cc59d..4237ebd818b 100644 --- a/Resources/Changelog/ChangelogSunrise.yml +++ b/Resources/Changelog/ChangelogSunrise.yml @@ -247,3 +247,12 @@ Entries: type: Tweak id: 21 time: '2024-06-05T16:26:42.210195+00:00' +- author: VigersRay + changes: + - message: "\u041E\u0437\u0432\u0443\u0447\u043A\u0430 \u043E\u043F\u043E\u0432\u0435\ + \u0449\u0435\u043D\u0438\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 \u043D\u0435\ + \ \u043D\u0430\u043A\u043B\u0430\u0434\u044B\u0432\u0430\u0435\u0442\u0441\u044F\ + \ \u0434\u0440\u0443\u0433 \u043D\u0430 \u0434\u0440\u0443\u0433\u0430." + type: Fix + id: 22 + time: '2024-06-07T08:01:08.686524+00:00'