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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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("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;
foreach (var proto in _prototypeManager.EnumeratePrototypes<RoundAnnouncementPrototype>())
{
if (!proto.GamePresets.Contains(Preset.ID)) continue;
var options = _prototypeManager.EnumeratePrototypes<RoundAnnouncementPrototype>().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());
}
}

View File

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