Fix some announcements code (#16585)

This commit is contained in:
metalgearsloth
2023-05-21 20:06:05 +10:00
committed by GitHub
parent 48ad2e7d22
commit 8edfedfba5
3 changed files with 9 additions and 18 deletions

View File

@@ -17,7 +17,4 @@ public sealed class RoundAnnouncementPrototype : IPrototype
[DataField("sound")] public SoundSpecifier? Sound; [DataField("sound")] public SoundSpecifier? Sound;
[DataField("message")] public string? Message; [DataField("message")] public string? Message;
[DataField("presets", customTypeSerializer: typeof(PrototypeIdListSerializer<GamePresetPrototype>))]
public List<string> GamePresets = new();
} }

View File

@@ -524,19 +524,18 @@ namespace Content.Server.GameTicking
{ {
if (Preset == null) return; if (Preset == null) return;
foreach (var proto in _prototypeManager.EnumeratePrototypes<RoundAnnouncementPrototype>()) var options = _prototypeManager.EnumeratePrototypes<RoundAnnouncementPrototype>().ToList();
{
if (!proto.GamePresets.Contains(Preset.ID)) continue; if (options.Count == 0)
return;
var proto = _robustRandom.Pick(options);
if (proto.Message != null) if (proto.Message != null)
_chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true); _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true);
if (proto.Sound != null) if (proto.Sound != null)
SoundSystem.Play(proto.Sound.GetSound(), Filter.Broadcast()); SoundSystem.Play(proto.Sound.GetSound(), Filter.Broadcast());
// Only play one because A
break;
}
} }
} }

View File

@@ -1,8 +1,3 @@
- type: roundAnnouncement - type: roundAnnouncement
id: Welcome id: Welcome
sound: /Audio/Announcements/welcome.ogg sound: /Audio/Announcements/welcome.ogg
presets:
- Survival
- Sandbox
- Secret
- Traitor