From eaf3493d30bf6d9a1ce9126223e139ec655862f6 Mon Sep 17 00:00:00 2001 From: pheenty Date: Mon, 21 Oct 2024 20:55:58 +0700 Subject: [PATCH] playsound parameter --- Content.Server/Stories/Nightvision/NightvisionSystem.cs | 3 ++- Content.Shared/Stories/Nightvision/NightvisionComponent.cs | 5 +++++ .../Stories/Nightvision/SharedNightvisionSystem.cs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Server/Stories/Nightvision/NightvisionSystem.cs b/Content.Server/Stories/Nightvision/NightvisionSystem.cs index 534489e64e..8076fba08f 100644 --- a/Content.Server/Stories/Nightvision/NightvisionSystem.cs +++ b/Content.Server/Stories/Nightvision/NightvisionSystem.cs @@ -36,8 +36,9 @@ private void OnEquipped(EntityUid uid, NightvisionClothingComponent component, G } private void OnStartUp(EntityUid uid, NightvisionComponent component, ComponentStartup args) { + if (component.PlaySound) + _audio.PlayPvs(component.ToggleOnSound, uid); _actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction); - _audio.PlayPvs(component.ToggleOnSound, uid); } private void OnShutdown(EntityUid uid, NightvisionComponent component, ComponentShutdown args) { diff --git a/Content.Shared/Stories/Nightvision/NightvisionComponent.cs b/Content.Shared/Stories/Nightvision/NightvisionComponent.cs index 09a79e121c..53e896cf02 100644 --- a/Content.Shared/Stories/Nightvision/NightvisionComponent.cs +++ b/Content.Shared/Stories/Nightvision/NightvisionComponent.cs @@ -11,8 +11,13 @@ public sealed partial class NightvisionComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField("enabled"), AutoNetworkedField] public bool Enabled { get; set; } = true; + [DataField] public string ToggleAction = "ToggleNightvisionAction"; + [DataField, AutoNetworkedField] public EntityUid? ToggleActionEntity; + [ViewVariables(VVAccess.ReadWrite), DataField("playSound"), AutoNetworkedField] + public bool PlaySound { get; set; } = true; // For dragon + [DataField("toggleOnSound")] public SoundSpecifier ToggleOnSound = new SoundPathSpecifier("/Audio/Stories/Misc/night_vision.ogg"); } diff --git a/Content.Shared/Stories/Nightvision/SharedNightvisionSystem.cs b/Content.Shared/Stories/Nightvision/SharedNightvisionSystem.cs index cb22556253..f081323d70 100644 --- a/Content.Shared/Stories/Nightvision/SharedNightvisionSystem.cs +++ b/Content.Shared/Stories/Nightvision/SharedNightvisionSystem.cs @@ -16,7 +16,7 @@ private void OnToggle(EntityUid uid, NightvisionComponent component, ToggleNight if (!_timing.IsFirstTimePredicted) return; component.Enabled = !component.Enabled; - if (component.Enabled) + if (component.Enabled && component.PlaySound) _audio.PlayPredicted(component.ToggleOnSound, uid, uid); } }