From ebc1bff4cb5847ed28432d626fe7772b8b503dc9 Mon Sep 17 00:00:00 2001
From: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Date: Tue, 25 Feb 2025 00:16:10 +0300
Subject: [PATCH] Cleanup: Use ``SoundCollectionSpecifier`` instead of string
literals in ``PowerGridCheckRule`` (#35449)
* Cleanup
* Update
* .
* Volume
---
.../Components/PowerGridCheckRuleComponent.cs | 13 +++++++++++++
.../StationEvents/Events/PowerGridCheckRule.cs | 2 +-
.../Prototypes/SoundCollections/announcements.yml | 5 +++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/Content.Server/StationEvents/Components/PowerGridCheckRuleComponent.cs b/Content.Server/StationEvents/Components/PowerGridCheckRuleComponent.cs
index 98c60346c7..757a4f18b5 100644
--- a/Content.Server/StationEvents/Components/PowerGridCheckRuleComponent.cs
+++ b/Content.Server/StationEvents/Components/PowerGridCheckRuleComponent.cs
@@ -1,11 +1,24 @@
using System.Threading;
using Content.Server.StationEvents.Events;
+using Robust.Shared.Audio;
+using Robust.Shared.Prototypes;
namespace Content.Server.StationEvents.Components;
[RegisterComponent, Access(typeof(PowerGridCheckRule))]
public sealed partial class PowerGridCheckRuleComponent : Component
{
+ ///
+ /// Default sound of the announcement when power is back on.
+ ///
+ private static readonly ProtoId DefaultPowerOn = new("PowerOn");
+
+ ///
+ /// Sound of the announcement to play when power is back on.
+ ///
+ [DataField]
+ public SoundSpecifier PowerOnSound = new SoundCollectionSpecifier(DefaultPowerOn, AudioParams.Default.WithVolume(-4f));
+
public CancellationTokenSource? AnnounceCancelToken;
public EntityUid AffectedStation;
diff --git a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs
index a4594e1387..3a86f694ab 100644
--- a/Content.Server/StationEvents/Events/PowerGridCheckRule.cs
+++ b/Content.Server/StationEvents/Events/PowerGridCheckRule.cs
@@ -59,7 +59,7 @@ namespace Content.Server.StationEvents.Events
component.AnnounceCancelToken = new CancellationTokenSource();
Timer.Spawn(3000, () =>
{
- Audio.PlayGlobal("/Audio/Announcements/power_on.ogg", Filter.Broadcast(), true, AudioParams.Default.WithVolume(-4f));
+ Audio.PlayGlobal(component.PowerOnSound, Filter.Broadcast(), true);
}, component.AnnounceCancelToken.Token);
component.Unpowered.Clear();
}
diff --git a/Resources/Prototypes/SoundCollections/announcements.yml b/Resources/Prototypes/SoundCollections/announcements.yml
index cb90b2282c..25abb2457a 100644
--- a/Resources/Prototypes/SoundCollections/announcements.yml
+++ b/Resources/Prototypes/SoundCollections/announcements.yml
@@ -4,3 +4,8 @@
- /Audio/Announcements/RoundEnd/apc_destroyed.ogg
- /Audio/Announcements/RoundEnd/disappointed.ogg
- /Audio/Announcements/RoundEnd/notevenpaidforthis.ogg
+
+- type: soundCollection
+ id: PowerOn
+ files:
+ - /Audio/Announcements/power_on.ogg
--
2.51.2