From 8edfedfba5d249c197abdc8585fc986d78072628 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 21 May 2023 20:06:05 +1000 Subject: [PATCH] Fix some announcements code (#16585) --- .../RoundAnnouncementPrototype.cs | 3 --- .../GameTicking/GameTicker.RoundFlow.cs | 19 +++++++++---------- Resources/Prototypes/round_announcements.yml | 5 ----- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Content.Server/Announcements/RoundAnnouncementPrototype.cs b/Content.Server/Announcements/RoundAnnouncementPrototype.cs index 680c6b228f..039acf41f5 100644 --- a/Content.Server/Announcements/RoundAnnouncementPrototype.cs +++ b/Content.Server/Announcements/RoundAnnouncementPrototype.cs @@ -17,7 +17,4 @@ public sealed class RoundAnnouncementPrototype : IPrototype [DataField("sound")] public SoundSpecifier? Sound; [DataField("message")] public string? Message; - - [DataField("presets", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List GamePresets = new(); } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 5ea96ff82c..7697e927ac 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -524,19 +524,18 @@ namespace Content.Server.GameTicking { if (Preset == null) return; - foreach (var proto in _prototypeManager.EnumeratePrototypes()) - { - if (!proto.GamePresets.Contains(Preset.ID)) continue; + var options = _prototypeManager.EnumeratePrototypes().ToList(); - if (proto.Message != null) - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true); + if (options.Count == 0) + return; - if (proto.Sound != null) - SoundSystem.Play(proto.Sound.GetSound(), Filter.Broadcast()); + var proto = _robustRandom.Pick(options); - // Only play one because A - break; - } + if (proto.Message != null) + _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true); + + if (proto.Sound != null) + SoundSystem.Play(proto.Sound.GetSound(), Filter.Broadcast()); } } diff --git a/Resources/Prototypes/round_announcements.yml b/Resources/Prototypes/round_announcements.yml index 0496bb4b22..070de0cb7f 100644 --- a/Resources/Prototypes/round_announcements.yml +++ b/Resources/Prototypes/round_announcements.yml @@ -1,8 +1,3 @@ - type: roundAnnouncement id: Welcome sound: /Audio/Announcements/welcome.ogg - presets: - - Survival - - Sandbox - - Secret - - Traitor