Cleanup: Use `SoundCollectionSpecifier instead of string literals in PowerGridCheckRule` (#35449)

* Cleanup

* Update

* .

* Volume
This commit is contained in:
Winkarst
2025-02-25 00:16:10 +03:00
committed by GitHub
parent c899ae7649
commit ebc1bff4cb
3 changed files with 19 additions and 1 deletions

View File

@@ -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
{
/// <summary>
/// Default sound of the announcement when power is back on.
/// </summary>
private static readonly ProtoId<SoundCollectionPrototype> DefaultPowerOn = new("PowerOn");
/// <summary>
/// Sound of the announcement to play when power is back on.
/// </summary>
[DataField]
public SoundSpecifier PowerOnSound = new SoundCollectionSpecifier(DefaultPowerOn, AudioParams.Default.WithVolume(-4f));
public CancellationTokenSource? AnnounceCancelToken;
public EntityUid AffectedStation;

View File

@@ -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();
}

View File

@@ -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