Round start audio announcement (#8047)
This commit is contained in:
23
Content.Server/Announcements/RoundAnnouncementPrototype.cs
Normal file
23
Content.Server/Announcements/RoundAnnouncementPrototype.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Content.Server.GameTicking.Presets;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Server.Announcements;
|
||||
|
||||
/// <summary>
|
||||
/// Used for any announcements on the start of a round.
|
||||
/// </summary>
|
||||
[Prototype("roundAnnouncement")]
|
||||
public sealed class RoundAnnouncementPrototype : IPrototype
|
||||
{
|
||||
[IdDataFieldAttribute]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("sound")] public SoundSpecifier? Sound;
|
||||
|
||||
[DataField("message")] public string? Message;
|
||||
|
||||
[DataField("presets", customTypeSerializer: typeof(PrototypeIdListSerializer<GamePresetPrototype>))]
|
||||
public List<string> GamePresets = new();
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Announcements;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Maps;
|
||||
@@ -10,11 +11,13 @@ using Content.Shared.CCVar;
|
||||
using Content.Shared.Coordinates;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Station;
|
||||
using JetBrains.Annotations;
|
||||
using Prometheus;
|
||||
using Robust.Server.Maps;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
@@ -214,6 +217,7 @@ namespace Content.Server.GameTicking
|
||||
ReqWindowAttentionAll();
|
||||
UpdateLateJoinStatus();
|
||||
UpdateJobsAvailable();
|
||||
AnnounceRound();
|
||||
|
||||
#if EXCEPTION_TOLERANCE
|
||||
}
|
||||
@@ -466,6 +470,25 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
return _gameTiming.RealTime.Subtract(_roundStartTimeSpan);
|
||||
}
|
||||
|
||||
private void AnnounceRound()
|
||||
{
|
||||
if (_preset == null) return;
|
||||
|
||||
foreach (var proto in _prototypeManager.EnumeratePrototypes<RoundAnnouncementPrototype>())
|
||||
{
|
||||
if (!proto.GamePresets.Contains(_preset.ID)) continue;
|
||||
|
||||
if (proto.Message != null)
|
||||
_chatManager.DispatchStationAnnouncement(Loc.GetString(proto.Message), playDefaultSound: false);
|
||||
|
||||
if (proto.Sound != null)
|
||||
SoundSystem.Play(Filter.Broadcast(), proto.Sound.GetSound());
|
||||
|
||||
// Only play one because A
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum GameRunLevel
|
||||
|
||||
Reference in New Issue
Block a user