Skip to content

Commit

Permalink
playsound parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
pheenty committed Oct 21, 2024
1 parent f1d7905 commit eaf3493
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Content.Server/Stories/Nightvision/NightvisionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
5 changes: 5 additions & 0 deletions Content.Shared/Stories/Nightvision/NightvisionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit eaf3493

Please sign in to comment.