replacing sound (collection) names with SoundSpecifier - part 1

This commit is contained in:
Galactic Chimp
2021-07-10 17:35:33 +02:00
parent 4500b66f28
commit ce3c59e0e6
131 changed files with 934 additions and 587 deletions

View File

@@ -1,26 +1,39 @@
using Content.Shared.PDA; using Content.Shared.PDA;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players; using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Client.PDA namespace Content.Client.PDA
{ {
[RegisterComponent] [RegisterComponent]
public class PDAComponent : SharedPDAComponent public class PDAComponent : SharedPDAComponent
{ {
[ViewVariables]
[DataField("buySuccessSound")]
private SoundSpecifier BuySuccessSound { get; } = new SoundPathSpecifier("/Audio/Effects/kaching.ogg");
[ViewVariables]
[DataField("insufficientFundsSound")]
private SoundSpecifier InsufficientFundsSound { get; } = new SoundPathSpecifier("/Audio/Effects/error.ogg");
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
{ {
base.HandleNetworkMessage(message, netChannel, session); base.HandleNetworkMessage(message, netChannel, session);
switch(message) switch(message)
{ {
case PDAUplinkBuySuccessMessage _ : case PDAUplinkBuySuccessMessage:
SoundSystem.Play(Filter.Local(), "/Audio/Effects/kaching.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(BuySuccessSound.TryGetSound(out var buySuccessSound))
SoundSystem.Play(Filter.Local(), buySuccessSound, Owner, AudioParams.Default.WithVolume(-2f));
break; break;
case PDAUplinkInsufficientFundsMessage _ : case PDAUplinkInsufficientFundsMessage:
SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); if(InsufficientFundsSound.TryGetSound(out var insufficientFundsSound))
SoundSystem.Play(Filter.Local(), insufficientFundsSound, Owner, AudioParams.Default);
break; break;
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Server.Destructible; using Content.Server.Destructible;
using Content.Server.Destructible.Thresholds; using Content.Server.Destructible.Thresholds;
@@ -100,7 +100,7 @@ namespace Content.IntegrationTests.Tests.Destructible
var actsThreshold = (DoActsBehavior) threshold.Behaviors[2]; var actsThreshold = (DoActsBehavior) threshold.Behaviors[2];
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
@@ -164,7 +164,7 @@ namespace Content.IntegrationTests.Tests.Destructible
// Check that it matches the YAML prototype // Check that it matches the YAML prototype
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));
@@ -215,7 +215,7 @@ namespace Content.IntegrationTests.Tests.Destructible
// Check that it matches the YAML prototype // Check that it matches the YAML prototype
Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage)); Assert.That(actsThreshold.Acts, Is.EqualTo(ThresholdActs.Breakage));
Assert.That(soundThreshold.Sound, Is.EqualTo("/Audio/Effects/woodhit.ogg")); Assert.That(soundThreshold.Sound.GetSound(), Is.EqualTo("/Audio/Effects/woodhit.ogg"));
Assert.That(spawnThreshold.Spawn, Is.Not.Null); Assert.That(spawnThreshold.Spawn, Is.Not.Null);
Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1)); Assert.That(spawnThreshold.Spawn.Count, Is.EqualTo(1));
Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId)); Assert.That(spawnThreshold.Spawn.Single().Key, Is.EqualTo(SpawnedEntityId));

View File

@@ -11,12 +11,14 @@ using Content.Shared.AME;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.AME.Components namespace Content.Server.AME.Components
@@ -32,6 +34,8 @@ namespace Content.Server.AME.Components
private AppearanceComponent? _appearance; private AppearanceComponent? _appearance;
private PowerSupplierComponent? _powerSupplier; private PowerSupplierComponent? _powerSupplier;
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("injectSound")] private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg");
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
@@ -312,12 +316,14 @@ namespace Content.Server.AME.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var clickSound))
SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f));
} }
private void InjectSound(bool overloading) private void InjectSound(bool overloading)
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); if(_injectSound.TryGetSound(out var injectSound))
SoundSystem.Play(Filter.Pvs(Owner), injectSound, Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
} }
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)

View File

@@ -4,8 +4,8 @@ using System.Threading.Tasks;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Tools.Components; using Content.Server.Tools.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Tool; using Content.Shared.Tool;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -14,6 +14,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.AME.Components namespace Content.Server.AME.Components
{ {
@@ -25,7 +26,7 @@ namespace Content.Server.AME.Components
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!; [Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
public override string Name => "AMEPart"; public override string Name => "AMEPart";
private string _unwrap = "/Audio/Effects/unwrap.ogg"; [DataField("unwrapSound")] private SoundSpecifier _unwrapSound = new SoundPathSpecifier("/Audio/Effects/unwrap.ogg");
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)
{ {
@@ -51,7 +52,8 @@ namespace Content.Server.AME.Components
var ent = _serverEntityManager.SpawnEntity("AMEShielding", mapGrid.GridTileToLocal(snapPos)); var ent = _serverEntityManager.SpawnEntity("AMEShielding", mapGrid.GridTileToLocal(snapPos));
ent.Transform.LocalRotation = Owner.Transform.LocalRotation; ent.Transform.LocalRotation = Owner.Transform.LocalRotation;
SoundSystem.Play(Filter.Pvs(Owner), _unwrap, Owner); if(_unwrapSound.TryGetSound(out var unwrapSound))
SoundSystem.Play(Filter.Pvs(Owner), unwrapSound, Owner);
Owner.Delete(); Owner.Delete();

View File

@@ -1,6 +1,4 @@
#nullable enable #nullable enable
using System;
using System.Linq;
using Content.Server.Act; using Content.Server.Act;
using Content.Server.Interaction; using Content.Server.Interaction;
using Content.Server.Notification; using Content.Server.Notification;
@@ -11,9 +9,9 @@ using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components; using Content.Shared.Actions.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Cooldown; using Content.Shared.Cooldown;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -24,6 +22,9 @@ using Robust.Shared.Maths;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System;
using System.Linq;
namespace Content.Server.Actions.Actions namespace Content.Server.Actions.Actions
{ {
@@ -35,6 +36,14 @@ namespace Content.Server.Actions.Actions
[DataField("pushProb")] private float _pushProb = 0.4f; [DataField("pushProb")] private float _pushProb = 0.4f;
[DataField("cooldown")] private float _cooldown = 1.5f; [DataField("cooldown")] private float _cooldown = 1.5f;
[ViewVariables]
[DataField("punchMissSound")]
private SoundSpecifier PunchMissSound { get; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg");
[ViewVariables]
[DataField("disarmSuccessSound")]
private SoundSpecifier DisarmSuccessSound { get; } = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
public void DoTargetEntityAction(TargetEntityActionEventArgs args) public void DoTargetEntityAction(TargetEntityActionEventArgs args)
{ {
var disarmedActs = args.Target.GetAllComponents<IDisarmedAct>().ToArray(); var disarmedActs = args.Target.GetAllComponents<IDisarmedAct>().ToArray();
@@ -70,8 +79,9 @@ namespace Content.Server.Actions.Actions
if (random.Prob(_failProb)) if (random.Prob(_failProb))
{ {
SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Weapons/punchmiss.ogg", args.Performer, if(PunchMissSound.TryGetSound(out var punchMissSound))
AudioHelpers.WithVariation(0.025f)); SoundSystem.Play(Filter.Pvs(args.Performer), punchMissSound, args.Performer, AudioHelpers.WithVariation(0.025f));
args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients", args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients",
("performerName", args.Performer.Name), ("performerName", args.Performer.Name),
("targetName", args.Target.Name))); ("targetName", args.Target.Name)));
@@ -94,8 +104,8 @@ namespace Content.Server.Actions.Actions
return; return;
} }
SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Effects/thudswoosh.ogg", args.Performer.Transform.Coordinates, if(DisarmSuccessSound.TryGetSound(out var disarmSuccessSound))
AudioHelpers.WithVariation(0.025f)); SoundSystem.Play(Filter.Pvs(args.Performer), disarmSuccessSound, args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f));
} }
} }
} }

View File

@@ -1,6 +1,4 @@
#nullable enable #nullable enable
using System;
using System.Collections.Generic;
using Content.Server.CharacterAppearance.Components; using Content.Server.CharacterAppearance.Components;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Actions.Behaviors; using Content.Shared.Actions.Behaviors;
@@ -8,7 +6,7 @@ using Content.Shared.Actions.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.CharacterAppearance; using Content.Shared.CharacterAppearance;
using Content.Shared.Cooldown; using Content.Shared.Cooldown;
using Content.Shared.Speech; using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -16,6 +14,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using System;
namespace Content.Server.Actions.Actions namespace Content.Server.Actions.Actions
{ {
@@ -28,9 +27,9 @@ namespace Content.Server.Actions.Actions
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
[DataField("male")] private List<string>? _male; [DataField("male")] private SoundSpecifier _male = default!;
[DataField("female")] private List<string>? _female; [DataField("female")] private SoundSpecifier _female = default!;
[DataField("wilhelm")] private string? _wilhelm; [DataField("wilhelm")] private SoundSpecifier _wilhelm = default!;
/// seconds /// seconds
[DataField("cooldown")] private float _cooldown = 10; [DataField("cooldown")] private float _cooldown = 10;
@@ -46,31 +45,27 @@ namespace Content.Server.Actions.Actions
if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return; if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return;
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return; if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
if (_random.Prob(.01f) && !string.IsNullOrWhiteSpace(_wilhelm)) if (_random.Prob(.01f) && _wilhelm.TryGetSound(out var wilhelm))
{ {
SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); SoundSystem.Play(Filter.Pvs(args.Performer), wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume));
} }
else else
{ {
switch (humanoid.Sex) switch (humanoid.Sex)
{ {
case Sex.Male: case Sex.Male:
if (_male == null) break; if (_male.TryGetSound(out var male))
SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_male), args.Performer, SoundSystem.Play(Filter.Pvs(args.Performer), male, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
AudioHelpers.WithVariation(Variation).WithVolume(Volume));
break; break;
case Sex.Female: case Sex.Female:
if (_female == null) break; if (_female.TryGetSound(out var female))
SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_female), args.Performer, SoundSystem.Play(Filter.Pvs(args.Performer), female, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
AudioHelpers.WithVariation(Variation).WithVolume(Volume));
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
} }
actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown));
} }
} }

View File

@@ -6,6 +6,7 @@ using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components; using Content.Shared.Actions.Components;
using Content.Shared.Cooldown; using Content.Shared.Cooldown;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -27,7 +28,7 @@ namespace Content.Server.Actions.Spells
[ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f; [ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f;
[ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!; [ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!;
[ViewVariables] [DataField("castSound")] public string? CastSound { get; set; } = default!; [ViewVariables] [DataField("castSound")] public SoundSpecifier CastSound { get; set; } = default!;
//Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns //Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns
//Not sure if needs fixing //Not sure if needs fixing
@@ -68,8 +69,8 @@ namespace Content.Server.Actions.Spells
handsComponent.PutInHandOrDrop(itemComponent); handsComponent.PutInHandOrDrop(itemComponent);
if (CastSound != null) if (CastSound.TryGetSound(out var castSound))
SoundSystem.Play(Filter.Pvs(caster), CastSound, caster); SoundSystem.Play(Filter.Pvs(caster), castSound, caster);
} }
} }
} }

View File

@@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Arcade; using Content.Shared.Arcade;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Wires; using Content.Shared.Wires;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -39,6 +40,13 @@ namespace Content.Server.Arcade.Components
[ViewVariables] private bool _enemyInvincibilityFlag; [ViewVariables] private bool _enemyInvincibilityFlag;
[ViewVariables] private SpaceVillainGame _game = null!; [ViewVariables] private SpaceVillainGame _game = null!;
[DataField("newGameSound")] private SoundSpecifier _newGameSound = new SoundPathSpecifier("/Audio/Effects/Arcade/newgame.ogg");
[DataField("playerAttackSound")] private SoundSpecifier _playerAttackSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_attack.ogg");
[DataField("playerHealSound")] private SoundSpecifier _playerHealSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_heal.ogg");
[DataField("playerChargeSound")] private SoundSpecifier _playerChargeSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_charge.ogg");
[DataField("winSound")] private SoundSpecifier _winSound = new SoundPathSpecifier("/Audio/Effects/Arcade/win.ogg");
[DataField("gameOverSound")] private SoundSpecifier _gameOverSound = new SoundPathSpecifier("/Audio/Effects/Arcade/gameover.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List<string> _possibleFightVerbs = new List<string>() [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List<string> _possibleFightVerbs = new List<string>()
{"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"}; {"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List<string> _possibleFirstEnemyNames = new List<string>(){ [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List<string> _possibleFirstEnemyNames = new List<string>(){
@@ -124,7 +132,9 @@ namespace Content.Server.Arcade.Components
_game?.ExecutePlayerAction(msg.PlayerAction); _game?.ExecutePlayerAction(msg.PlayerAction);
break; break;
case PlayerAction.NewGame: case PlayerAction.NewGame:
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/Arcade/newgame.ogg", Owner, AudioParams.Default.WithVolume(-4f)); if(_newGameSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-4f));
_game = new SpaceVillainGame(this); _game = new SpaceVillainGame(this);
UserInterface?.SendMessage(_game.GenerateMetaDataMessage()); UserInterface?.SendMessage(_game.GenerateMetaDataMessage());
break; break;
@@ -292,8 +302,10 @@ namespace Content.Server.Arcade.Components
_latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message", _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message",
("enemyName", _enemyName), ("enemyName", _enemyName),
("attackAmount", attackAmount)); ("attackAmount", attackAmount));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_attack.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if(_owner._playerAttackSound.TryGetSound(out var playerAttackSound))
if(!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; SoundSystem.Play(Filter.Pvs(_owner.Owner), playerAttackSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!_owner._enemyInvincibilityFlag)
_enemyHp -= attackAmount;
_turtleTracker -= _turtleTracker > 0 ? 1 : 0; _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
break; break;
case PlayerAction.Heal: case PlayerAction.Heal:
@@ -302,15 +314,18 @@ namespace Content.Server.Arcade.Components
_latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message", _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message",
("magicPointAmount", pointAmount), ("magicPointAmount", pointAmount),
("healAmount", healAmount)); ("healAmount", healAmount));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_heal.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if(_owner._playerHealSound.TryGetSound(out var playerHealSound))
if(!_owner._playerInvincibilityFlag) _playerMp -= pointAmount; SoundSystem.Play(Filter.Pvs(_owner.Owner), playerHealSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!_owner._playerInvincibilityFlag)
_playerMp -= pointAmount;
_playerHp += healAmount; _playerHp += healAmount;
_turtleTracker++; _turtleTracker++;
break; break;
case PlayerAction.Recharge: case PlayerAction.Recharge:
var chargeAmount = _random.Next(4, 7); var chargeAmount = _random.Next(4, 7);
_latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message",("regainedPoints", chargeAmount)); _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message",("regainedPoints", chargeAmount));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_charge.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if(_owner._playerChargeSound.TryGetSound(out var playerChargeSound))
SoundSystem.Play(Filter.Pvs(_owner.Owner), playerChargeSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
_playerMp += chargeAmount; _playerMp += chargeAmount;
_turtleTracker -= _turtleTracker > 0 ? 1 : 0; _turtleTracker -= _turtleTracker > 0 ? 1 : 0;
break; break;
@@ -344,7 +359,8 @@ namespace Content.Server.Arcade.Components
UpdateUi(Loc.GetString("space-villain-game-player-wins-message"), UpdateUi(Loc.GetString("space-villain-game-player-wins-message"),
Loc.GetString("space-villain-game-enemy-dies-message",("enemyName", _enemyName)), Loc.GetString("space-villain-game-enemy-dies-message",("enemyName", _enemyName)),
true); true);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/win.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if(_owner._winSound.TryGetSound(out var winSound))
SoundSystem.Play(Filter.Pvs(_owner.Owner), winSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
_owner.ProcessWin(); _owner.ProcessWin();
return false; return false;
} }
@@ -357,7 +373,8 @@ namespace Content.Server.Arcade.Components
UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), UpdateUi(Loc.GetString("space-villain-game-player-loses-message"),
Loc.GetString("space-villain-game-enemy-cheers-message",("enemyName", _enemyName)), Loc.GetString("space-villain-game-enemy-cheers-message",("enemyName", _enemyName)),
true); true);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if(_owner._gameOverSound.TryGetSound(out var gameOverSound))
SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
return false; return false;
} }
if (_enemyHp <= 0 || _enemyMp <= 0) if (_enemyHp <= 0 || _enemyMp <= 0)
@@ -366,7 +383,8 @@ namespace Content.Server.Arcade.Components
UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), UpdateUi(Loc.GetString("space-villain-game-player-loses-message"),
Loc.GetString("space-villain-game-enemy-dies-with-player-message ", ("enemyName", _enemyName)), Loc.GetString("space-villain-game-enemy-dies-with-player-message ", ("enemyName", _enemyName)),
true); true);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f)); if (_owner._gameOverSound.TryGetSound(out var gameOverSound))
SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f));
return false; return false;
} }

View File

@@ -18,6 +18,7 @@ using Content.Shared.Audio;
using Content.Shared.DragDrop; using Content.Shared.DragDrop;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -48,6 +49,8 @@ namespace Content.Server.Atmos.Components
[ViewVariables] private BoundUserInterface? _userInterface; [ViewVariables] private BoundUserInterface? _userInterface;
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
[DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new(); [DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new();
/// <summary> /// <summary>
@@ -282,8 +285,8 @@ namespace Content.Server.Atmos.Components
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(); var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere();
tileAtmos?.AssumeAir(Air); tileAtmos?.AssumeAir(Air);
SoundSystem.Play(Filter.Pvs(Owner), "Audio/Effects/spray.ogg", Owner.Transform.Coordinates, if(_ruptureSound.TryGetSound(out var sound))
AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f));
Owner.QueueDelete(); Owner.QueueDelete();
return; return;

View File

@@ -9,6 +9,7 @@ using Content.Shared.Body.Slot;
using Content.Shared.MobState; using Content.Shared.MobState;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Random.Helpers; using Content.Shared.Random.Helpers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -16,6 +17,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players; using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Body namespace Content.Server.Body
{ {
@@ -26,6 +28,8 @@ namespace Content.Server.Body
{ {
private Container _partContainer = default!; private Container _partContainer = default!;
[DataField("gibSound")] private SoundSpecifier _gibSound = new SoundCollectionSpecifier("gib");
protected override bool CanAddPart(string slotId, SharedBodyPartComponent part) protected override bool CanAddPart(string slotId, SharedBodyPartComponent part)
{ {
return base.CanAddPart(slotId, part) && return base.CanAddPart(slotId, part) &&
@@ -101,8 +105,8 @@ namespace Content.Server.Body
{ {
base.Gib(gibParts); base.Gib(gibParts);
SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("gib"), Owner.Transform.Coordinates, if(_gibSound.TryGetSound(out var sound))
AudioHelpers.WithVariation(0.025f)); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f));
if (Owner.TryGetComponent(out ContainerManagerComponent? container)) if (Owner.TryGetComponent(out ContainerManagerComponent? container))
{ {

View File

@@ -724,9 +724,9 @@ namespace Content.Server.Botany.Components
sprayed = true; sprayed = true;
amount = ReagentUnit.New(1); amount = ReagentUnit.New(1);
if (!string.IsNullOrEmpty(spray.SpraySound)) if (spray.SpraySound.TryGetSound(out var spraySound))
{ {
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(usingItem), spraySound, usingItem, AudioHelpers.WithVariation(0.125f));
} }
} }

View File

@@ -242,7 +242,10 @@ namespace Content.Server.Buckle.Components
return false; return false;
} }
SoundSystem.Play(Filter.Pvs(Owner), strap.BuckleSound, Owner); if(strap.BuckleSound.TryGetSound(out var buckleSound))
{
SoundSystem.Play(Filter.Pvs(Owner), buckleSound, Owner);
}
if (!strap.TryAdd(this)) if (!strap.TryAdd(this))
{ {
@@ -350,8 +353,11 @@ namespace Content.Server.Buckle.Components
UpdateBuckleStatus(); UpdateBuckleStatus();
oldBuckledTo.Remove(this); oldBuckledTo.Remove(this);
SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound, Owner); if (oldBuckledTo.UnbuckleSound.TryGetSound(out var unbuckleSound))
{
SoundSystem.Play(Filter.Pvs(Owner), unbuckleSound, Owner);
}
SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner)); SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner));
return true; return true;

View File

@@ -9,6 +9,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -56,14 +57,14 @@ namespace Content.Server.Buckle.Components
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("buckleSound")] [DataField("buckleSound")]
public string BuckleSound { get; } = "/Audio/Effects/buckle.ogg"; public SoundSpecifier BuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/buckle.ogg");
/// <summary> /// <summary>
/// The sound to be played when a mob is unbuckled /// The sound to be played when a mob is unbuckled
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("unbuckleSound")] [DataField("unbuckleSound")]
public string UnbuckleSound { get; } = "/Audio/Effects/unbuckle.ogg"; public SoundSpecifier UnbuckleSound { get; } = new SoundPathSpecifier("/Audio/Effects/unbuckle.ogg");
/// <summary> /// <summary>
/// ID of the alert to show when buckled /// ID of the alert to show when buckled

View File

@@ -1,5 +1,6 @@
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Content.Shared.Whitelist; using Content.Shared.Whitelist;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -24,7 +25,7 @@ namespace Content.Server.Cabinet
/// </summary> /// </summary>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("doorSound")] [DataField("doorSound")]
public string? DoorSound { get; set; } public SoundSpecifier DoorSound { get; set; } = default!;
/// <summary> /// <summary>
/// The prototype that should be spawned inside the cabinet when it is map initialized. /// The prototype that should be spawned inside the cabinet when it is map initialized.

View File

@@ -1,4 +1,4 @@
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.Items; using Content.Server.Items;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Cabinet; using Content.Shared.Cabinet;
@@ -146,8 +146,10 @@ namespace Content.Server.Cabinet
private static void ClickLatchSound(ItemCabinetComponent comp) private static void ClickLatchSound(ItemCabinetComponent comp)
{ {
if (comp.DoorSound == null) return; if(comp.DoorSound.TryGetSound(out var doorSound))
SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound, comp.Owner, AudioHelpers.WithVariation(0.15f)); {
SoundSystem.Play(Filter.Pvs(comp.Owner), doorSound, comp.Owner, AudioHelpers.WithVariation(0.15f));
}
} }
} }

View File

@@ -6,6 +6,7 @@ using Content.Server.UserInterface;
using Content.Shared.Cargo; using Content.Shared.Cargo;
using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -59,6 +60,9 @@ namespace Content.Server.Cargo.Components
[DataField("requestOnly")] [DataField("requestOnly")]
private bool _requestOnly = false; private bool _requestOnly = false;
[DataField("errorSound")]
private SoundSpecifier _errorSound = new SoundPathSpecifier("/Audio/Effects/error.ogg");
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
private CargoConsoleSystem _cargoConsoleSystem = default!; private CargoConsoleSystem _cargoConsoleSystem = default!;
@@ -112,9 +116,10 @@ namespace Content.Server.Cargo.Components
} }
if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId,
msg.Amount, _bankAccount.Id)) msg.Amount, _bankAccount.Id) &&
_errorSound.TryGetSound(out var errorSound))
{ {
SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default);
} }
break; break;
} }
@@ -137,14 +142,16 @@ namespace Content.Server.Cargo.Components
break; break;
var capacity = _cargoConsoleSystem.GetCapacity(orders.Database.Id); var capacity = _cargoConsoleSystem.GetCapacity(orders.Database.Id);
if ( if (
capacity.CurrentCapacity == capacity.MaxCapacity (capacity.CurrentCapacity == capacity.MaxCapacity
|| capacity.CurrentCapacity + order.Amount > capacity.MaxCapacity || capacity.CurrentCapacity + order.Amount > capacity.MaxCapacity
|| !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) || !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)
|| !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber) || !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber)
|| !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) || !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount))
&&
_errorSound.TryGetSound(out var errorSound)
) )
{ {
SoundSystem.Play(Filter.Local(), "/Audio/Effects/error.ogg", Owner, AudioParams.Default); SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default);
break; break;
} }
UpdateUIState(); UpdateUIState();

View File

@@ -2,10 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Shared.Cargo; using Content.Shared.Cargo;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Cargo.Components namespace Content.Server.Cargo.Components
{ {
@@ -21,6 +23,7 @@ namespace Content.Server.Cargo.Components
private const float TeleportDelay = 15f; private const float TeleportDelay = 15f;
private List<CargoProductPrototype> _teleportQueue = new List<CargoProductPrototype>(); private List<CargoProductPrototype> _teleportQueue = new List<CargoProductPrototype>();
private CargoTelepadState _currentState = CargoTelepadState.Unpowered; private CargoTelepadState _currentState = CargoTelepadState.Unpowered;
[DataField("teleportSound")] private SoundSpecifier _teleportSound = new SoundPathSpecifier("/Audio/Machines/phasein.ogg");
public override void HandleMessage(ComponentMessage message, IComponent? component) public override void HandleMessage(ComponentMessage message, IComponent? component)
{ {
@@ -72,7 +75,8 @@ namespace Content.Server.Cargo.Components
{ {
if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0)
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/phasein.ogg", Owner, AudioParams.Default.WithVolume(-8f)); if (_teleportSound.TryGetSound(out var teleportSound))
SoundSystem.Play(Filter.Pvs(Owner), teleportSound, Owner, AudioParams.Default.WithVolume(-8f));
Owner.EntityManager.SpawnEntity(_teleportQueue[0].Product, Owner.Transform.Coordinates); Owner.EntityManager.SpawnEntity(_teleportQueue[0].Product, Owner.Transform.Coordinates);
_teleportQueue.RemoveAt(0); _teleportQueue.RemoveAt(0);
if (Owner.TryGetComponent<SpriteComponent>(out var spriteComponent) && spriteComponent.LayerCount > 0) if (Owner.TryGetComponent<SpriteComponent>(out var spriteComponent) && spriteComponent.LayerCount > 0)

View File

@@ -14,6 +14,7 @@ using Content.Shared.Chemistry.Solution;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Random.Helpers; using Content.Shared.Random.Helpers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -21,6 +22,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.Chemistry.Components namespace Content.Server.Chemistry.Components
@@ -46,6 +48,8 @@ namespace Content.Server.Chemistry.Components
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ChemMasterUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ChemMasterUiKey.Key);
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
/// <summary> /// <summary>
/// Called once per instance of this component. Gets references to any other components needed /// Called once per instance of this component. Gets references to any other components needed
/// by this component and initializes it's UI and other data. /// by this component and initializes it's UI and other data.
@@ -417,7 +421,8 @@ namespace Content.Server.Chemistry.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
} }
[Verb] [Verb]

View File

@@ -5,6 +5,7 @@ using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -27,6 +28,9 @@ namespace Content.Server.Chemistry.Components
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5); public ReagentUnit TransferAmount { get; set; } = ReagentUnit.New(5);
[DataField("InjectSound")]
private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Items/hypospray.ogg");
[ComponentDependency] private readonly SolutionContainerComponent? _solution = default!; [ComponentDependency] private readonly SolutionContainerComponent? _solution = default!;
protected override void Initialize() protected override void Initialize()
@@ -68,7 +72,8 @@ namespace Content.Server.Chemistry.Components
meleeSys.SendLunge(angle, user); meleeSys.SendLunge(angle, user);
} }
SoundSystem.Play(Filter.Pvs(user), "/Audio/Items/hypospray.ogg", user); if(_injectSound.TryGetSound(out var injectSound))
SoundSystem.Play(Filter.Pvs(user), injectSound, user);
var targetSolution = target.GetComponent<SolutionContainerComponent>(); var targetSolution = target.GetComponent<SolutionContainerComponent>();

View File

@@ -7,6 +7,7 @@ using Content.Shared.Chemistry.Reagent;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -23,7 +24,7 @@ namespace Content.Server.Chemistry.Components
[ViewVariables] [ViewVariables]
[DataField("useSound")] [DataField("useSound")]
protected override string? UseSound { get; set; } = default; protected override SoundSpecifier UseSound { get; set; } = default!;
[ViewVariables] [ViewVariables]
[DataField("trash")] [DataField("trash")]
@@ -98,9 +99,9 @@ namespace Content.Server.Chemistry.Components
firstStomach.TryTransferSolution(split); firstStomach.TryTransferSolution(split);
if (UseSound != null) if (UseSound.TryGetSound(out var sound))
{ {
SoundSystem.Play(Filter.Pvs(trueTarget), UseSound, trueTarget, AudioParams.Default.WithVolume(-1f)); SoundSystem.Play(Filter.Pvs(trueTarget), sound, trueTarget, AudioParams.Default.WithVolume(-1f));
} }
trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message")); trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message"));

View File

@@ -14,6 +14,7 @@ using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution; using Content.Shared.Chemistry.Solution;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -47,6 +48,8 @@ namespace Content.Server.Chemistry.Components
[ViewVariables] private ContainerSlot _beakerContainer = default!; [ViewVariables] private ContainerSlot _beakerContainer = default!;
[ViewVariables] [DataField("pack")] private string _packPrototypeId = ""; [ViewVariables] [DataField("pack")] private string _packPrototypeId = "";
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null; [ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null;
[ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10); [ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10);
[UsedImplicitly] [ViewVariables] private SolutionContainerComponent? Solution => _beakerContainer.ContainedEntity?.GetComponent<SolutionContainerComponent>(); [UsedImplicitly] [ViewVariables] private SolutionContainerComponent? Solution => _beakerContainer.ContainedEntity?.GetComponent<SolutionContainerComponent>();
@@ -359,7 +362,8 @@ namespace Content.Server.Chemistry.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
} }
[Verb] [Verb]

View File

@@ -13,8 +13,8 @@ namespace Content.Server.Chemistry.EntitySystems
{ {
base.OnReaction(reaction, owner, unitReactions); base.OnReaction(reaction, owner, unitReactions);
if (reaction.Sound != null) if (reaction.Sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(owner), reaction.Sound, owner.Transform.Coordinates); SoundSystem.Play(Filter.Pvs(owner), sound, owner.Transform.Coordinates);
} }
} }
} }

View File

@@ -4,6 +4,7 @@ using Content.Server.Chemistry.Components;
using Content.Server.Coordinates.Helpers; using Content.Server.Coordinates.Helpers;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reaction;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -80,7 +81,7 @@ namespace Content.Server.Chemistry.ReactionEffects
/// <summary> /// <summary>
/// Sound that will get played when this reaction effect occurs. /// Sound that will get played when this reaction effect occurs.
/// </summary> /// </summary>
[DataField("sound")] private string? _sound; [DataField("sound")] private SoundSpecifier _sound = default!;
protected AreaReactionEffect() protected AreaReactionEffect()
{ {
@@ -136,9 +137,9 @@ namespace Content.Server.Chemistry.ReactionEffects
areaEffectComponent.TryAddSolution(solution); areaEffectComponent.TryAddSolution(solution);
areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay); areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay);
if (!string.IsNullOrEmpty(_sound)) if (_sound.TryGetSound(out var sound))
{ {
SoundSystem.Play(Filter.Pvs(solutionEntity), _sound, solutionEntity, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(solutionEntity), sound, solutionEntity, AudioHelpers.WithVariation(0.125f));
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Construction; using Content.Shared.Construction;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -14,21 +15,12 @@ namespace Content.Server.Construction.Completions
[DataDefinition] [DataDefinition]
public class PlaySound : IGraphAction public class PlaySound : IGraphAction
{ {
[DataField("soundCollection")] public string SoundCollection { get; private set; } = string.Empty; [DataField("sound")] public SoundSpecifier Sound { get; private set; } = default!;
[DataField("sound")] public string Sound { get; private set; } = string.Empty;
public async Task PerformAction(IEntity entity, IEntity? user) public async Task PerformAction(IEntity entity, IEntity? user)
{ {
var sound = GetSound(); if(Sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f));
if (string.IsNullOrEmpty(sound)) return;
SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f));
}
private string GetSound()
{
return !string.IsNullOrEmpty(SoundCollection) ? AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection) : Sound;
} }
} }
} }

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -31,7 +32,7 @@ namespace Content.Server.Crayon
//TODO: useSound //TODO: useSound
[DataField("useSound")] [DataField("useSound")]
private string? _useSound = string.Empty; private SoundSpecifier _useSound = default!;
[ViewVariables] [ViewVariables]
public Color Color { get; set; } public Color Color { get; set; }
@@ -135,9 +136,9 @@ namespace Content.Server.Crayon
appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation); appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation);
} }
if (!string.IsNullOrEmpty(_useSound)) if (_useSound.TryGetSound(out var useSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _useSound, Owner, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.125f));
} }
// Decrease "Ammo" // Decrease "Ammo"

View File

@@ -232,13 +232,13 @@ namespace Content.Server.Cuffs.Components
if (isOwner) if (isOwner)
{ {
if (cuff.StartBreakoutSound != null) if (cuff.StartBreakoutSound.TryGetSound(out var startBreakoutSound))
SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), startBreakoutSound, Owner);
} }
else else
{ {
if (cuff.StartUncuffSound != null) if (cuff.StartUncuffSound.TryGetSound(out var startUncuffSound))
SoundSystem.Play(Filter.Pvs(Owner), cuff.StartUncuffSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), startUncuffSound, Owner);
} }
var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime;
@@ -259,8 +259,8 @@ namespace Content.Server.Cuffs.Components
if (result != DoAfterStatus.Cancelled) if (result != DoAfterStatus.Cancelled)
{ {
if (cuff.EndUncuffSound != null) if (cuff.EndUncuffSound.TryGetSound(out var endUncuffSound))
SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), endUncuffSound, Owner);
Container.ForceRemove(cuffsToRemove); Container.ForceRemove(cuffsToRemove);
cuffsToRemove.Transform.AttachToGridOrMap(); cuffsToRemove.Transform.AttachToGridOrMap();

View File

@@ -10,6 +10,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -114,18 +115,18 @@ namespace Content.Server.Cuffs.Components
} }
[DataField("startCuffSound")] [DataField("startCuffSound")]
public string StartCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_start.ogg"; public SoundSpecifier StartCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg");
[DataField("endCuffSound")] public string EndCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_end.ogg"; [DataField("endCuffSound")] public SoundSpecifier EndCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg");
[DataField("startBreakoutSound")] [DataField("startBreakoutSound")]
public string StartBreakoutSound { get; set; } = "/Audio/Items/Handcuffs/cuff_breakout_start.ogg"; public SoundSpecifier StartBreakoutSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_breakout_start.ogg");
[DataField("startUncuffSound")] [DataField("startUncuffSound")]
public string StartUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_start.ogg"; public SoundSpecifier StartUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_start.ogg");
[DataField("endUncuffSound")] [DataField("endUncuffSound")]
public string EndUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_end.ogg"; public SoundSpecifier EndUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_end.ogg");
[DataField("color")] [DataField("color")]
public Color Color { get; set; } = Color.White; public Color Color { get; set; } = Color.White;
@@ -184,8 +185,8 @@ namespace Content.Server.Cuffs.Components
eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target))); eventArgs.User.PopupMessage(Loc.GetString("handcuff-component-start-cuffing-target-message",("targetName", eventArgs.Target)));
eventArgs.User.PopupMessage(eventArgs.Target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User))); eventArgs.User.PopupMessage(eventArgs.Target, Loc.GetString("handcuff-component-start-cuffing-by-other-message",("otherName", eventArgs.User)));
if (StartCuffSound != null) if (StartCuffSound.TryGetSound(out var startCuffSound))
SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), startCuffSound, Owner);
TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed); TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed);
return true; return true;
@@ -222,8 +223,8 @@ namespace Content.Server.Cuffs.Components
{ {
if (cuffs.TryAddNewCuffs(user, Owner)) if (cuffs.TryAddNewCuffs(user, Owner))
{ {
if (EndCuffSound != null) if (EndCuffSound.TryGetSound(out var endCuffSound))
SoundSystem.Play(Filter.Pvs(Owner), EndCuffSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), endCuffSound, Owner);
user.PopupMessage(Loc.GetString("handcuff-component-cuff-other-success-message",("otherName", target))); user.PopupMessage(Loc.GetString("handcuff-component-cuff-other-success-message",("otherName", target)));
target.PopupMessage(Loc.GetString("handcuff-component-cuff-by-other-success-message", ("otherName", user))); target.PopupMessage(Loc.GetString("handcuff-component-cuff-by-other-success-message", ("otherName", user)));

View File

@@ -1,8 +1,9 @@
using System; using System;
using Content.Server.Stunnable.Components; using Content.Server.Stunnable.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Components; using Content.Shared.Damage.Components;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -32,7 +33,7 @@ namespace Content.Server.Damage.Components
[DataField("factor")] [DataField("factor")]
public float Factor { get; set; } = 1f; public float Factor { get; set; } = 1f;
[DataField("soundHit")] [DataField("soundHit")]
public string SoundHit { get; set; } = ""; public SoundSpecifier SoundHit { get; set; } = default!;
[DataField("stunChance")] [DataField("stunChance")]
public float StunChance { get; set; } = 0.25f; public float StunChance { get; set; } = 0.25f;
[DataField("stunMinimumDamage")] [DataField("stunMinimumDamage")]
@@ -51,8 +52,8 @@ namespace Content.Server.Damage.Components
if (speed < MinimumSpeed) return; if (speed < MinimumSpeed) return;
if (!string.IsNullOrEmpty(SoundHit)) if (SoundHit.TryGetSound(out var soundHit))
SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), SoundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), soundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown) if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
return; return;

View File

@@ -1,5 +1,6 @@
using System; using System;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Player; using Robust.Shared.Player;
@@ -14,17 +15,15 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
/// <summary> /// <summary>
/// Sound played upon destruction. /// Sound played upon destruction.
/// </summary> /// </summary>
[DataField("sound")] public string Sound { get; set; } = string.Empty; [DataField("sound")] public SoundSpecifier Sound { get; set; } = default!;
public void Execute(IEntity owner, DestructibleSystem system) public void Execute(IEntity owner, DestructibleSystem system)
{ {
if (string.IsNullOrEmpty(Sound)) if (Sound.TryGetSound(out var sound))
{ {
return; var pos = owner.Transform.Coordinates;
} SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f));
}
var pos = owner.Transform.Coordinates;
SoundSystem.Play(Filter.Pvs(pos), Sound, pos, AudioHelpers.WithVariation(0.125f));
} }
} }
} }

View File

@@ -1,33 +0,0 @@
using System;
using Content.Shared.Audio;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Destructible.Thresholds.Behaviors
{
[Serializable]
[DataDefinition]
public class PlaySoundCollectionBehavior : IThresholdBehavior
{
/// <summary>
/// Sound collection from which to pick a random sound to play.
/// </summary>
[DataField("soundCollection")]
private string SoundCollection { get; set; } = string.Empty;
public void Execute(IEntity owner, DestructibleSystem system)
{
if (string.IsNullOrEmpty(SoundCollection))
{
return;
}
var sound = AudioHelpers.GetRandomFileFromSoundCollection(SoundCollection);
var pos = owner.Transform.Coordinates;
SoundSystem.Play(Filter.Pvs(pos), sound, pos, AudioHelpers.WithVariation(0.125f));
}
}
}

View File

@@ -64,7 +64,8 @@ namespace Content.Server.Dice
public void PlayDiceEffect() public void PlayDiceEffect()
{ {
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioParams.Default); if(_sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
} }
void IActivate.Activate(ActivateEventArgs eventArgs) void IActivate.Activate(ActivateEventArgs eventArgs)

View File

@@ -24,6 +24,7 @@ using Content.Shared.Interaction;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -88,6 +89,9 @@ namespace Content.Server.Disposal.Mailing
[DataField("entryDelay")] [DataField("entryDelay")]
private float _entryDelay = 0.5f; private float _entryDelay = 0.5f;
[DataField("receivedMessageSound")]
private SoundSpecifier _receivedMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
/// <summary> /// <summary>
/// Token used to cancel the automatic engage of a disposal unit /// Token used to cancel the automatic engage of a disposal unit
/// after an entity enters it. /// after an entity enters it.
@@ -432,8 +436,8 @@ namespace Content.Server.Disposal.Mailing
break; break;
case UiButton.Power: case UiButton.Power:
TogglePower(); TogglePower();
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_receivedMessageSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();

View File

@@ -9,6 +9,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -20,6 +21,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent; using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
@@ -42,6 +44,8 @@ namespace Content.Server.Disposal.Tube.Components
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
public override Direction NextDirection(DisposalHolderComponent holder) public override Direction NextDirection(DisposalHolderComponent holder)
{ {
var directions = ConnectableDirections(); var directions = ConnectableDirections();
@@ -150,7 +154,8 @@ namespace Content.Server.Disposal.Tube.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
} }
/// <summary> /// <summary>

View File

@@ -6,6 +6,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -17,6 +18,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent; using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent;
@@ -39,6 +41,8 @@ namespace Content.Server.Disposal.Tube.Components
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key);
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
public override Direction NextDirection(DisposalHolderComponent holder) public override Direction NextDirection(DisposalHolderComponent holder)
{ {
holder.Tags.Add(_tag); holder.Tags.Add(_tag);
@@ -116,7 +120,8 @@ namespace Content.Server.Disposal.Tube.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
} }
/// <summary> /// <summary>

View File

@@ -8,6 +8,7 @@ using Content.Shared.Disposal.Components;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Console; using Robust.Server.Console;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -37,7 +38,7 @@ namespace Content.Server.Disposal.Tube.Components
private bool _connected; private bool _connected;
private bool _broken; private bool _broken;
[DataField("clangSound")] [DataField("clangSound")]
private string _clangSound = "/Audio/Effects/clang.ogg"; private SoundSpecifier _clangSound = new SoundPathSpecifier("/Audio/Effects/clang.ogg");
/// <summary> /// <summary>
/// Container of entities that are currently inside this tube /// Container of entities that are currently inside this tube
@@ -266,7 +267,8 @@ namespace Content.Server.Disposal.Tube.Components
} }
_lastClang = _gameTiming.CurTime; _lastClang = _gameTiming.CurTime;
SoundSystem.Play(Filter.Pvs(Owner), _clangSound, Owner.Transform.Coordinates); if(_clangSound.TryGetSound(out var clangSound))
SoundSystem.Play(Filter.Pvs(Owner), clangSound, Owner.Transform.Coordinates);
break; break;
} }
} }

View File

@@ -20,6 +20,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -78,6 +79,8 @@ namespace Content.Server.Disposal.Unit.Components
[DataField("flushDelay")] [DataField("flushDelay")]
private readonly TimeSpan _flushDelay = TimeSpan.FromSeconds(3); private readonly TimeSpan _flushDelay = TimeSpan.FromSeconds(3);
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
/// <summary> /// <summary>
/// Delay from trying to enter disposals ourselves. /// Delay from trying to enter disposals ourselves.
/// </summary> /// </summary>
@@ -377,7 +380,8 @@ namespace Content.Server.Disposal.Unit.Components
break; break;
case UiButton.Power: case UiButton.Power:
TogglePower(); TogglePower();
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var clickSound))
SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f));
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();

View File

@@ -8,12 +8,14 @@ using Content.Shared.Doors;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Shared.Wires.SharedWiresComponent; using static Content.Shared.Wires.SharedWiresComponent;
using static Content.Shared.Wires.SharedWiresComponent.WiresAction; using static Content.Shared.Wires.SharedWiresComponent.WiresAction;
@@ -92,6 +94,10 @@ namespace Content.Server.Doors.Components
} }
} }
[DataField("setBoltsDownSound")] private SoundSpecifier _setBoltsDownSound = new SoundPathSpecifier("/Audio/Machines/boltsdown.ogg");
[DataField("setBoltsUpSound")] private SoundSpecifier _setBoltsUpSound = new SoundPathSpecifier("/Audio/Machines/boltsup.ogg");
private static readonly TimeSpan AutoCloseDelayFast = TimeSpan.FromSeconds(1); private static readonly TimeSpan AutoCloseDelayFast = TimeSpan.FromSeconds(1);
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
@@ -456,7 +462,16 @@ namespace Content.Server.Doors.Components
BoltsDown = newBolts; BoltsDown = newBolts;
SoundSystem.Play(Filter.Broadcast(), newBolts ? "/Audio/Machines/boltsdown.ogg" : "/Audio/Machines/boltsup.ogg", Owner); if (newBolts)
{
if (_setBoltsDownSound.TryGetSound(out var boltsDownSound))
SoundSystem.Play(Filter.Broadcast(), boltsDownSound, Owner);
}
else
{
if (_setBoltsUpSound.TryGetSound(out var boltsUpSound))
SoundSystem.Play(Filter.Broadcast(), boltsUpSound, Owner);
}
} }
} }
} }

View File

@@ -14,6 +14,7 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Components; using Content.Shared.Damage.Components;
using Content.Shared.Doors; using Content.Shared.Doors;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.Tool; using Content.Shared.Tool;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -43,6 +44,9 @@ namespace Content.Server.Doors.Components
[DataField("board")] [DataField("board")]
private string? _boardPrototype; private string? _boardPrototype;
[DataField("tryOpenDoorSound")]
private SoundSpecifier _tryOpenDoorSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg");
public override DoorState State public override DoorState State
{ {
get => base.State; get => base.State;
@@ -235,10 +239,10 @@ namespace Content.Server.Doors.Components
{ {
Open(); Open();
if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0) if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0
&& _tryOpenDoorSound.TryGetSound(out var tryOpenDoorSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner, SoundSystem.Play(Filter.Pvs(Owner), tryOpenDoorSound, Owner, AudioParams.Default.WithVolume(-2));
AudioParams.Default.WithVolume(-2));
} }
} }
else else

View File

@@ -1,6 +1,7 @@
using Content.Server.Flash.Components; using Content.Server.Flash.Components;
using Content.Server.Storage.Components; using Content.Server.Storage.Components;
using Content.Shared.Acts; using Content.Shared.Acts;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -22,7 +23,7 @@ namespace Content.Server.Explosion.Components
[DataField("duration")] [DataField("duration")]
private float _duration = 8.0f; private float _duration = 8.0f;
[DataField("sound")] [DataField("sound")]
private string _sound = "/Audio/Effects/flash_bang.ogg"; private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg");
[DataField("deleteOnFlash")] [DataField("deleteOnFlash")]
private bool _deleteOnFlash = true; private bool _deleteOnFlash = true;
@@ -35,9 +36,9 @@ namespace Content.Server.Explosion.Components
FlashableComponent.FlashAreaHelper(Owner, _range, _duration); FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
} }
if (_sound != null) if (_sound.TryGetSound(out var sound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates);
} }
if (_deleteOnFlash && !Owner.Deleted) if (_deleteOnFlash && !Owner.Deleted)

View File

@@ -8,6 +8,7 @@ using Content.Shared.Acts;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -36,6 +37,7 @@ namespace Content.Server.Explosion
/// </summary> /// </summary>
private static readonly float LightBreakChance = 0.3f; private static readonly float LightBreakChance = 0.3f;
private static readonly float HeavyBreakChance = 0.8f; private static readonly float HeavyBreakChance = 0.8f;
private static SoundSpecifier _explosionSound = new SoundPathSpecifier("/Audio/Effects/explosion.ogg");
private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable"); private static bool IgnoreExplosivePassable(IEntity e) => e.HasTag("ExplosivePassable");
@@ -311,7 +313,8 @@ namespace Content.Server.Explosion
var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange), var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange),
epicenterMapPos + new Vector2(maxRange, maxRange)); epicenterMapPos + new Vector2(maxRange, maxRange));
SoundSystem.Play(Filter.Broadcast(), "/Audio/Effects/explosion.ogg", epicenter); if(_explosionSound.TryGetSound(out var explosionSound))
SoundSystem.Play(Filter.Broadcast(), explosionSound, epicenter);
DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId); DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId);
var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox); var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox);

View File

@@ -5,10 +5,12 @@ using Content.Shared.Chemistry.Solution.Components;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
#nullable enable #nullable enable
@@ -19,6 +21,8 @@ namespace Content.Server.Extinguisher
{ {
public override string Name => "FireExtinguisher"; public override string Name => "FireExtinguisher";
[DataField("refillSound")] SoundSpecifier _refillSound = new SoundPathSpecifier("/Audio/Effects/refill.ogg");
// Higher priority than sprays. // Higher priority than sprays.
int IAfterInteract.Priority => 1; int IAfterInteract.Priority => 1;
@@ -40,7 +44,8 @@ namespace Content.Server.Extinguisher
var drained = targetSolution.Drain(trans); var drained = targetSolution.Drain(trans);
container.TryAddSolution(drained); container.TryAddSolution(drained);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/refill.ogg", Owner); if(_refillSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner);
eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner))); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner)));
} }

View File

@@ -1,3 +1,4 @@
using Content.Shared.Sound;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -29,6 +30,10 @@ namespace Content.Server.Flash.Components
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public float SlowTo { get; set; } = 0.5f; public float SlowTo { get; set; } = 0.5f;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sound")]
public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/flash.ogg");
public bool Flashing; public bool Flashing;
public bool HasUses => Uses > 0; public bool HasUses => Uses > 0;

View File

@@ -2,6 +2,7 @@ using System;
using Content.Shared.Flash; using Content.Shared.Flash;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -31,7 +32,7 @@ namespace Content.Server.Flash.Components
return new FlashComponentState(_duration, _lastFlash); return new FlashComponentState(_duration, _lastFlash);
} }
public static void FlashAreaHelper(IEntity source, float range, float duration, string? sound = null) public static void FlashAreaHelper(IEntity source, float range, float duration, SoundSpecifier? sound = null)
{ {
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(source.Transform.Coordinates, range)) foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(source.Transform.Coordinates, range))
{ {
@@ -41,9 +42,9 @@ namespace Content.Server.Flash.Components
flashable.Flash(duration); flashable.Flash(duration);
} }
if (!string.IsNullOrEmpty(sound)) if (sound != null && sound.TryGetSound(out var soundName))
{ {
SoundSystem.Play(Filter.Pvs(source), sound, source.Transform.Coordinates); SoundSystem.Play(Filter.Pvs(source), soundName, source.Transform.Coordinates);
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using Content.Server.Flash.Components; using Content.Server.Flash.Components;
using Content.Server.Stunnable.Components; using Content.Server.Stunnable.Components;
using Content.Server.Weapon.Melee; using Content.Server.Weapon.Melee;
using Content.Shared.Examine; using Content.Shared.Examine;
@@ -93,8 +93,8 @@ namespace Content.Server.Flash
}); });
} }
SoundSystem.Play(Filter.Pvs(comp.Owner), "/Audio/Weapons/flash.ogg", comp.Owner.Transform.Coordinates, if(comp.Sound.TryGetSound(out var sound))
AudioParams.Default); SoundSystem.Play(Filter.Pvs(comp.Owner), sound, comp.Owner.Transform.Coordinates, AudioParams.Default);
return true; return true;
} }

View File

@@ -8,6 +8,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -43,7 +44,7 @@ namespace Content.Server.Fluids.Components
: ReagentUnit.Zero; : ReagentUnit.Zero;
[DataField("sound")] [DataField("sound")]
private string? _sound = "/Audio/Effects/Fluids/watersplash.ogg"; private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Effects/Fluids/watersplash.ogg");
/// <inheritdoc /> /// <inheritdoc />
protected override void Initialize() protected override void Initialize()
@@ -114,9 +115,9 @@ namespace Content.Server.Fluids.Components
return false; return false;
} }
if (_sound != null) if (_sound.TryGetSound(out var sound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner);
} }
return true; return true;

View File

@@ -7,6 +7,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -54,7 +55,7 @@ namespace Content.Server.Fluids.Components
public ReagentUnit PickupAmount { get; } = ReagentUnit.New(5); public ReagentUnit PickupAmount { get; } = ReagentUnit.New(5);
[DataField("pickup_sound")] [DataField("pickup_sound")]
private string? _pickupSound = "/Audio/Effects/Fluids/slosh.ogg"; private SoundSpecifier _pickupSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
/// <summary> /// <summary>
/// Multiplier for the do_after delay for how fast the mop works. /// Multiplier for the do_after delay for how fast the mop works.
@@ -163,9 +164,9 @@ namespace Content.Server.Fluids.Components
contents.SplitSolution(transferAmount); contents.SplitSolution(transferAmount);
} }
if (!string.IsNullOrWhiteSpace(_pickupSound)) if (_pickupSound.TryGetSound(out var pickupSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _pickupSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), pickupSound, Owner);
} }
return true; return true;

View File

@@ -11,6 +11,7 @@ using Content.Shared.Examine;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Slippery; using Content.Shared.Slippery;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -71,7 +72,7 @@ namespace Content.Server.Fluids.Components
public float EvaporateTime { get; private set; } = 5f; public float EvaporateTime { get; private set; } = 5f;
[DataField("spill_sound")] [DataField("spill_sound")]
private string _spillSound = "/Audio/Effects/Fluids/splat.ogg"; private SoundSpecifier _spillSound = new SoundPathSpecifier("/Audio/Effects/Fluids/splat.ogg");
/// <summary> /// <summary>
/// Whether or not this puddle is currently overflowing onto its neighbors /// Whether or not this puddle is currently overflowing onto its neighbors
@@ -189,7 +190,8 @@ namespace Content.Server.Fluids.Components
return true; return true;
} }
SoundSystem.Play(Filter.Pvs(Owner), _spillSound, Owner.Transform.Coordinates); if(_spillSound.TryGetSound(out var spillSound))
SoundSystem.Play(Filter.Pvs(Owner), spillSound, Owner.Transform.Coordinates);
return true; return true;
} }

View File

@@ -10,6 +10,7 @@ using Content.Shared.Fluids;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Vapor; using Content.Shared.Vapor;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -35,8 +36,6 @@ namespace Content.Server.Fluids.Components
[DataField("transferAmount")] [DataField("transferAmount")]
private ReagentUnit _transferAmount = ReagentUnit.New(10); private ReagentUnit _transferAmount = ReagentUnit.New(10);
[DataField("spraySound")]
private string? _spraySound;
[DataField("sprayVelocity")] [DataField("sprayVelocity")]
private float _sprayVelocity = 1.5f; private float _sprayVelocity = 1.5f;
[DataField("sprayAliveTime")] [DataField("sprayAliveTime")]
@@ -78,7 +77,8 @@ namespace Content.Server.Fluids.Components
set => _sprayVelocity = value; set => _sprayVelocity = value;
} }
public string? SpraySound => _spraySound; [DataField("spraySound")]
public SoundSpecifier SpraySound { get; } = default!;
public ReagentUnit CurrentVolume => Owner.GetComponentOrNull<SolutionContainerComponent>()?.CurrentVolume ?? ReagentUnit.Zero; public ReagentUnit CurrentVolume => Owner.GetComponentOrNull<SolutionContainerComponent>()?.CurrentVolume ?? ReagentUnit.Zero;
@@ -172,9 +172,9 @@ namespace Content.Server.Fluids.Components
} }
//Play sound //Play sound
if (!string.IsNullOrEmpty(_spraySound)) if (SpraySound.TryGetSound(out var spraySound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _spraySound, Owner, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), spraySound, Owner, AudioHelpers.WithVariation(0.125f));
} }
_lastUseTime = curTime; _lastUseTime = curTime;

View File

@@ -9,6 +9,7 @@ using Content.Server.Suspicion.Roles;
using Content.Shared; using Content.Shared;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.MobState; using Content.Shared.MobState;
using Content.Shared.Sound;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Configuration; using Robust.Shared.Configuration;
@@ -16,6 +17,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Timer = Robust.Shared.Timing.Timer; using Timer = Robust.Shared.Timing.Timer;
@@ -33,6 +35,8 @@ namespace Content.Server.GameTicking.Rules
[Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
private readonly CancellationTokenSource _checkTimerCancel = new(); private readonly CancellationTokenSource _checkTimerCancel = new();
private TimeSpan _endTime; private TimeSpan _endTime;
@@ -49,7 +53,9 @@ namespace Content.Server.GameTicking.Rules
var filter = Filter.Empty() var filter = Filter.Empty()
.AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole<SuspicionTraitorRole>() ?? false); .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole<SuspicionTraitorRole>() ?? false);
SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default);
if(_addedSound.TryGetSound(out var addedSound))
SoundSystem.Play(filter, addedSound, AudioParams.Default);
EntitySystem.Get<SuspicionEndTimerSystem>().EndTime = _endTime; EntitySystem.Get<SuspicionEndTimerSystem>().EndTime = _endTime;
EntitySystem.Get<DoorSystem>().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal; EntitySystem.Get<DoorSystem>().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal;

View File

@@ -1,11 +1,13 @@
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.Players; using Content.Server.Players;
using Content.Server.Traitor; using Content.Server.Traitor;
using Content.Shared.Sound;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameTicking.Rules namespace Content.Server.GameTicking.Rules
{ {
@@ -13,13 +15,17 @@ namespace Content.Server.GameTicking.Rules
{ {
[Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly IChatManager _chatManager = default!;
[DataField("addedSound")] private SoundSpecifier _addedSound = new SoundPathSpecifier("/Audio/Misc/tatoralert.ogg");
public override void Added() public override void Added()
{ {
_chatManager.DispatchServerAnnouncement(Loc.GetString("rule-traitor-added-announcement")); _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-traitor-added-announcement"));
var filter = Filter.Empty() var filter = Filter.Empty()
.AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole<TraitorRole>() ?? false); .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole<TraitorRole>() ?? false);
SoundSystem.Play(filter, "/Audio/Misc/tatoralert.ogg", AudioParams.Default);
if(_addedSound.TryGetSound(out var addedSound))
SoundSystem.Play(filter, addedSound, AudioParams.Default);
} }
} }
} }

View File

@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.Camera; using Content.Server.Camera;
using Content.Shared.Gravity; using Content.Shared.Gravity;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -108,7 +109,7 @@ namespace Content.Server.Gravity.EntitySystems
comp.Enabled = true; comp.Enabled = true;
var gridId = comp.Owner.Transform.GridID; var gridId = comp.Owner.Transform.GridID;
ScheduleGridToShake(gridId, ShakeTimes); ScheduleGridToShake(gridId, ShakeTimes, comp);
var message = new GravityChangedMessage(gridId, true); var message = new GravityChangedMessage(gridId, true);
RaiseLocalEvent(message); RaiseLocalEvent(message);
@@ -120,13 +121,13 @@ namespace Content.Server.Gravity.EntitySystems
comp.Enabled = false; comp.Enabled = false;
var gridId = comp.Owner.Transform.GridID; var gridId = comp.Owner.Transform.GridID;
ScheduleGridToShake(gridId, ShakeTimes); ScheduleGridToShake(gridId, ShakeTimes, comp);
var message = new GravityChangedMessage(gridId, false); var message = new GravityChangedMessage(gridId, false);
RaiseLocalEvent(message); RaiseLocalEvent(message);
} }
private void ScheduleGridToShake(GridId gridId, uint shakeTimes) private void ScheduleGridToShake(GridId gridId, uint shakeTimes, GravityComponent comp)
{ {
if (!_gridsToShake.Keys.Contains(gridId)) if (!_gridsToShake.Keys.Contains(gridId))
{ {
@@ -140,8 +141,11 @@ namespace Content.Server.Gravity.EntitySystems
foreach (var player in _playerManager.GetAllPlayers()) foreach (var player in _playerManager.GetAllPlayers())
{ {
if (player.AttachedEntity == null if (player.AttachedEntity == null
|| player.AttachedEntity.Transform.GridID != gridId) continue; || player.AttachedEntity.Transform.GridID != gridId)
SoundSystem.Play(Filter.Pvs(player.AttachedEntity), "/Audio/Effects/alert.ogg", player.AttachedEntity); continue;
if(comp.GravityShakeSound.TryGetSound(out var gravityShakeSound))
SoundSystem.Play(Filter.Pvs(player.AttachedEntity), gravityShakeSound, player.AttachedEntity);
} }
} }

View File

@@ -13,6 +13,7 @@ using Content.Shared.Hands.Components;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components; using Content.Shared.Pulling.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -23,6 +24,7 @@ using Robust.Shared.Map;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players; using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Hands.Components namespace Content.Server.Hands.Components
{ {
@@ -34,6 +36,8 @@ namespace Content.Server.Hands.Components
{ {
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run. int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run.
public override void HandleMessage(ComponentMessage message, IComponent? component) public override void HandleMessage(ComponentMessage message, IComponent? component)
@@ -175,8 +179,8 @@ namespace Content.Server.Hands.Components
if (source != null) if (source != null)
{ {
SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source, if(_disarmedSound.TryGetSound(out var disarmedSound))
AudioHelpers.WithVariation(0.025f)); SoundSystem.Play(Filter.Pvs(source), disarmedSound, source, AudioHelpers.WithVariation(0.025f));
if (target != null) if (target != null)
{ {

View File

@@ -161,8 +161,8 @@ namespace Content.Server.Kitchen.Components
// TODO: Need to be able to leave them on the spike to do DoT, see ss13. // TODO: Need to be able to leave them on the spike to do DoT, see ss13.
victim.Delete(); victim.Delete();
if (SpikeSound != null) if (SpikeSound.TryGetSound(out var spikeSound))
SoundSystem.Play(Filter.Pvs(Owner), SpikeSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), spikeSound, Owner);
} }
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

@@ -24,6 +24,7 @@ using Content.Shared.Kitchen.Components;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Power; using Content.Shared.Power;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -50,12 +51,14 @@ namespace Content.Server.Kitchen.Components
[DataField("failureResult")] [DataField("failureResult")]
private string _badRecipeName = "FoodBadRecipe"; private string _badRecipeName = "FoodBadRecipe";
[DataField("beginCookingSound")] [DataField("beginCookingSound")]
private string _startCookingSound = "/Audio/Machines/microwave_start_beep.ogg"; private SoundSpecifier _startCookingSound = new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg");
[DataField("foodDoneSound")] [DataField("foodDoneSound")]
private string _cookingCompleteSound = "/Audio/Machines/microwave_done_beep.ogg"; private SoundSpecifier _cookingCompleteSound = new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg");
#endregion [DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
#endregion YAMLSERIALIZE
[ViewVariables] [ViewVariables]
private bool _busy = false; private bool _busy = false;
private bool _broken; private bool _broken;
@@ -335,7 +338,8 @@ namespace Content.Server.Kitchen.Components
} }
SetAppearance(MicrowaveVisualState.Cooking); SetAppearance(MicrowaveVisualState.Cooking);
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound, Owner, AudioParams.Default); if(_startCookingSound.TryGetSound(out var startCookingSound))
SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default);
Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() =>
{ {
if (_lostPower) if (_lostPower)
@@ -362,7 +366,9 @@ namespace Content.Server.Kitchen.Components
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
} }
} }
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound))
SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
SetAppearance(MicrowaveVisualState.Idle); SetAppearance(MicrowaveVisualState.Idle);
_busy = false; _busy = false;
@@ -495,7 +501,8 @@ namespace Content.Server.Kitchen.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var clickSound))
SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f));
} }
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

@@ -13,6 +13,7 @@ using Content.Shared.Kitchen.Components;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Random.Helpers; using Content.Shared.Random.Helpers;
using Content.Shared.Sound;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -67,6 +68,9 @@ namespace Content.Server.Kitchen.Components
//YAML serialization vars //YAML serialization vars
[ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] private int _storageCap = 16; [ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] private int _storageCap = 16;
[ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] private int _workTime = 3500; //3.5 seconds, completely arbitrary for now. [ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] private int _workTime = 3500; //3.5 seconds, completely arbitrary for now.
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("grindSound")] private SoundSpecifier _grindSound = new SoundPathSpecifier("/Audio/Machines/blender.ogg");
[DataField("juiceSound")] private SoundSpecifier _juiceSound = new SoundPathSpecifier("/Audio/Machines/juicer.ogg");
protected override void Initialize() protected override void Initialize()
{ {
@@ -163,7 +167,8 @@ namespace Content.Server.Kitchen.Components
private void ClickSound() private void ClickSound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
} }
private void SetAppearance() private void SetAppearance()
@@ -327,7 +332,8 @@ namespace Content.Server.Kitchen.Components
switch (program) switch (program)
{ {
case GrinderProgram.Grind: case GrinderProgram.Grind:
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/blender.ogg", Owner, AudioParams.Default); if(_grindSound.TryGetSound(out var grindSound))
SoundSystem.Play(Filter.Pvs(Owner), grindSound, Owner, AudioParams.Default);
//Get each item inside the chamber and get the reagents it contains. Transfer those reagents to the beaker, given we have one in. //Get each item inside the chamber and get the reagents it contains. Transfer those reagents to the beaker, given we have one in.
Owner.SpawnTimer(_workTime, (Action) (() => Owner.SpawnTimer(_workTime, (Action) (() =>
{ {
@@ -348,7 +354,8 @@ namespace Content.Server.Kitchen.Components
break; break;
case GrinderProgram.Juice: case GrinderProgram.Juice:
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/juicer.ogg", Owner, AudioParams.Default); if(_juiceSound.TryGetSound(out var juiceSound))
SoundSystem.Play(Filter.Pvs(Owner), juiceSound, Owner, AudioParams.Default);
Owner.SpawnTimer(_workTime, (Action) (() => Owner.SpawnTimer(_workTime, (Action) (() =>
{ {
foreach (var item in _chamber.ContainedEntities.ToList()) foreach (var item in _chamber.ContainedEntities.ToList())

View File

@@ -106,9 +106,9 @@ namespace Content.Server.Light.Components
loopingSound.Play(LoopedSound, LoopedSoundParams); loopingSound.Play(LoopedSound, LoopedSoundParams);
} }
if (LitSound != string.Empty) if (LitSound.TryGetSound(out var litSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), LitSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner);
} }
if (IconStateLit != string.Empty) if (IconStateLit != string.Empty)
@@ -126,9 +126,9 @@ namespace Content.Server.Light.Components
default: default:
case ExpendableLightState.Dead: case ExpendableLightState.Dead:
if (DieSound != string.Empty) if (DieSound.TryGetSound(out var dieSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), DieSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner);
} }
if (LoopedSound != string.Empty && Owner.TryGetComponent<LoopingLoopingSoundComponent>(out var loopSound)) if (LoopedSound != string.Empty && Owner.TryGetComponent<LoopingLoopingSoundComponent>(out var loopSound))

View File

@@ -13,6 +13,7 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Light.Component; using Content.Shared.Light.Component;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Rounding; using Content.Shared.Rounding;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -46,9 +47,9 @@ namespace Content.Server.Light.Components
[ViewVariables] protected override bool HasCell => _cellSlot.HasCell; [ViewVariables] protected override bool HasCell => _cellSlot.HasCell;
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public string? TurnOnSound = "/Audio/Items/flashlight_toggle.ogg"; [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public string? TurnOnFailSound = "/Audio/Machines/button.ogg"; [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public string? TurnOffSound = "/Audio/Items/flashlight_toggle.ogg"; [ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[ComponentDependency] private readonly ItemActionsComponent? _itemActions = null; [ComponentDependency] private readonly ItemActionsComponent? _itemActions = null;
@@ -120,9 +121,9 @@ namespace Content.Server.Light.Components
UpdateLightAction(); UpdateLightAction();
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this)); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this));
if (makeNoise) if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound))
{ {
if (TurnOffSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner);
} }
return true; return true;
@@ -137,7 +138,8 @@ namespace Content.Server.Light.Components
if (Cell == null) if (Cell == null)
{ {
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner); if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message")); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message"));
UpdateLightAction(); UpdateLightAction();
return false; return false;
@@ -148,7 +150,8 @@ namespace Content.Server.Light.Components
// Simple enough. // Simple enough.
if (Wattage > Cell.CurrentCharge) if (Wattage > Cell.CurrentCharge)
{ {
if (TurnOnFailSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound, Owner); if (TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner);
Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message")); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message"));
UpdateLightAction(); UpdateLightAction();
return false; return false;
@@ -159,7 +162,8 @@ namespace Content.Server.Light.Components
SetState(true); SetState(true);
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this)); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
if (TurnOnSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound, Owner); if (TurnOnSound.TryGetSound(out var turnOnSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner);
return true; return true;
} }

View File

@@ -2,6 +2,7 @@
using System; using System;
using Content.Shared.Acts; using Content.Shared.Acts;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Sound;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -71,6 +72,9 @@ namespace Content.Server.Light.Components
private int _powerUse = 40; private int _powerUse = 40;
public int PowerUse => _powerUse; public int PowerUse => _powerUse;
[DataField("breakSound")]
private SoundSpecifier _breakSound = new SoundCollectionSpecifier("GlassBreak");
/// <summary> /// <summary>
/// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set. /// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set.
/// It also updates the bulb's sprite accordingly. /// It also updates the bulb's sprite accordingly.
@@ -129,10 +133,8 @@ namespace Content.Server.Light.Components
public void PlayBreakSound() public void PlayBreakSound()
{ {
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("GlassBreak"); if(_breakSound.TryGetSound(out var breakSound))
var file = _random.Pick(soundCollection.PickFiles); SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner);
} }
} }
} }

View File

@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Smoking; using Content.Shared.Smoking;
using Content.Shared.Sound;
using Content.Shared.Temperature; using Content.Shared.Temperature;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -30,7 +31,7 @@ namespace Content.Server.Light.Components
/// <summary> /// <summary>
/// Sound played when you ignite the matchstick. /// Sound played when you ignite the matchstick.
/// </summary> /// </summary>
[DataField("igniteSound")] private string? _igniteSound; [DataField("igniteSound")] private SoundSpecifier _igniteSound = default!;
/// <summary> /// <summary>
/// Point light component. Gives matches a glow in dark effect. /// Point light component. Gives matches a glow in dark effect.
@@ -69,9 +70,9 @@ namespace Content.Server.Light.Components
public void Ignite(IEntity user) public void Ignite(IEntity user)
{ {
// Play Sound // Play Sound
if (!string.IsNullOrEmpty(_igniteSound)) if (_igniteSound.TryGetSound(out var igniteSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _igniteSound, Owner, SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner,
AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
} }

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interaction;
using Content.Shared.Light; using Content.Shared.Light;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -49,6 +50,12 @@ namespace Content.Server.Light.Components
private TimeSpan _lastThunk; private TimeSpan _lastThunk;
private TimeSpan? _lastGhostBlink; private TimeSpan? _lastGhostBlink;
[DataField("burnHandSound")]
private SoundSpecifier _burnHandSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");
[DataField("turnOnSound")]
private SoundSpecifier _turnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg");
[DataField("hasLampOnSpawn")] [DataField("hasLampOnSpawn")]
private bool _hasLampOnSpawn = true; private bool _hasLampOnSpawn = true;
@@ -119,7 +126,8 @@ namespace Content.Server.Light.Components
{ {
Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand")); Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand"));
damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner); damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/lightburn.ogg", Owner); if(_burnHandSound.TryGetSound(out var burnHandSound))
SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner);
} }
void Eject() void Eject()
@@ -221,7 +229,8 @@ namespace Content.Server.Light.Components
if (time > _lastThunk + _thunkDelay) if (time > _lastThunk + _thunkDelay)
{ {
_lastThunk = time; _lastThunk = time;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/light_tube_on.ogg", Owner, AudioParams.Default.WithVolume(-10f)); if(_turnOnSound.TryGetSound(out var turnOnSound))
SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f));
} }
} }
else else

View File

@@ -34,14 +34,17 @@ namespace Content.Server.Mining.Components
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
{ {
var item = eventArgs.Using; var item = eventArgs.Using;
if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent)) return false; if (!item.TryGetComponent(out MeleeWeaponComponent? meleeWeaponComponent))
return false;
Owner.GetComponent<IDamageableComponent>().ChangeDamage(DamageType.Blunt, meleeWeaponComponent.Damage, false, item); Owner.GetComponent<IDamageableComponent>().ChangeDamage(DamageType.Blunt, meleeWeaponComponent.Damage, false, item);
if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) return true; if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent))
if (!string.IsNullOrWhiteSpace(pickaxeComponent.MiningSound)) return true;
if (pickaxeComponent.MiningSound.TryGetSound(out var miningSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound, Owner, AudioParams.Default); SoundSystem.Play(Filter.Pvs(Owner), miningSound, Owner, AudioParams.Default);
} }
return true; return true;
} }

View File

@@ -1,3 +1,4 @@
using Content.Shared.Sound;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
@@ -5,12 +6,13 @@ namespace Content.Server.Mining.Components
{ {
[RegisterComponent] [RegisterComponent]
public class PickaxeComponent : Component public class PickaxeComponent : Component
{ {
public override string Name => "Pickaxe"; public override string Name => "Pickaxe";
[DataField("miningSound")] [DataField("miningSound")]
public string MiningSound = "/Audio/Items/Mining/pickaxe.ogg"; public SoundSpecifier MiningSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Mining/pickaxe.ogg");
[DataField("miningSpeedMultiplier")] [DataField("miningSpeedMultiplier")]
public float MiningSpeedMultiplier = 1f; public float MiningSpeedMultiplier { get; set; } = 1f;
} }
} }

View File

@@ -12,6 +12,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Morgue; using Content.Shared.Morgue;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.Player; using Robust.Server.Player;
@@ -20,6 +21,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -34,6 +36,8 @@ namespace Content.Server.Morgue.Components
{ {
public override string Name => "CrematoriumEntityStorage"; public override string Name => "CrematoriumEntityStorage";
[DataField("cremateFinishSound")] private SoundSpecifier _cremateFinishSound = new SoundPathSpecifier("/Audio/Machines/ding.ogg");
[ViewVariables] [ViewVariables]
public bool Cooking { get; private set; } public bool Cooking { get; private set; }
@@ -50,7 +54,7 @@ namespace Content.Server.Morgue.Components
{ {
if (Appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) if (Appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning)
{ {
message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning",("owner", Owner)) + "\n"); message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n");
} }
if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
@@ -68,7 +72,8 @@ namespace Content.Server.Morgue.Components
{ {
if (Cooking) if (Cooking)
{ {
if (!silent) Owner.PopupMessage(user, Loc.GetString("crematorium-entity-storage-component-is-cooking-safety-message")); if (!silent)
Owner.PopupMessage(user, Loc.GetString("crematorium-entity-storage-component-is-cooking-safety-message"));
return false; return false;
} }
return base.CanOpen(user, silent); return base.CanOpen(user, silent);
@@ -116,7 +121,9 @@ namespace Content.Server.Morgue.Components
TryOpenStorage(Owner); TryOpenStorage(Owner);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/ding.ogg", Owner); if (_cremateFinishSound.TryGetSound(out var cremateFinishSound))
SoundSystem.Play(Filter.Pvs(Owner), cremateFinishSound, Owner);
}, _cremateCancelToken.Token); }, _cremateCancelToken.Token);
} }

View File

@@ -8,6 +8,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Morgue; using Content.Shared.Morgue;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Standing; using Content.Shared.Standing;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -44,6 +45,9 @@ namespace Content.Server.Morgue.Components
[DataField("doSoulBeep")] [DataField("doSoulBeep")]
public bool DoSoulBeep = true; public bool DoSoulBeep = true;
[DataField("occupantHasSoulAlarmSound")]
private SoundSpecifier _occupantHasSoulAlarmSound = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg");
[ViewVariables] [ViewVariables]
[ComponentDependency] protected readonly AppearanceComponent? Appearance = null; [ComponentDependency] protected readonly AppearanceComponent? Appearance = null;
@@ -56,13 +60,15 @@ namespace Content.Server.Morgue.Components
public override Vector2 ContentsDumpPosition() public override Vector2 ContentsDumpPosition()
{ {
if (_tray != null) return _tray.Transform.WorldPosition; if (_tray != null)
return _tray.Transform.WorldPosition;
return base.ContentsDumpPosition(); return base.ContentsDumpPosition();
} }
protected override bool AddToContents(IEntity entity) protected override bool AddToContents(IEntity entity)
{ {
if (entity.HasComponent<SharedBodyComponent>() && !EntitySystem.Get<StandingStateSystem>().IsDown(entity)) return false; if (entity.HasComponent<SharedBodyComponent>() && !EntitySystem.Get<StandingStateSystem>().IsDown(entity))
return false;
return base.AddToContents(entity); return base.AddToContents(entity);
} }
@@ -73,7 +79,8 @@ namespace Content.Server.Morgue.Components
collisionMask: CollisionGroup.Impassable | CollisionGroup.VaultImpassable collisionMask: CollisionGroup.Impassable | CollisionGroup.VaultImpassable
)) ))
{ {
if(!silent) Owner.PopupMessage(user, Loc.GetString("morgue-entity-storage-component-cannot-open-no-space")); if (!silent)
Owner.PopupMessage(user, Loc.GetString("morgue-entity-storage-component-cannot-open-no-space"));
return false; return false;
} }
@@ -112,8 +119,10 @@ namespace Content.Server.Morgue.Components
foreach (var entity in Contents.ContainedEntities) foreach (var entity in Contents.ContainedEntities)
{ {
count++; count++;
if (!hasMob && entity.HasComponent<SharedBodyComponent>()) hasMob = true; if (!hasMob && entity.HasComponent<SharedBodyComponent>())
if (!hasSoul && entity.TryGetComponent<ActorComponent>(out var actor) && actor.PlayerSession != null) hasSoul = true; hasMob = true;
if (!hasSoul && entity.TryGetComponent<ActorComponent>(out var actor) && actor.PlayerSession != null)
hasSoul = true;
} }
Appearance?.SetData(MorgueVisuals.HasContents, count > 0); Appearance?.SetData(MorgueVisuals.HasContents, count > 0);
Appearance?.SetData(MorgueVisuals.HasMob, hasMob); Appearance?.SetData(MorgueVisuals.HasMob, hasMob);
@@ -138,8 +147,11 @@ namespace Content.Server.Morgue.Components
{ {
CheckContents(); CheckContents();
if(DoSoulBeep && Appearance !=null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul &&
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg", Owner); _occupantHasSoulAlarmSound.TryGetSound(out var occupantHasSoulAlarmSound))
{
SoundSystem.Play(Filter.Pvs(Owner), occupantHasSoulAlarmSound, Owner);
}
} }
void IExamine.Examine(FormattedMessage message, bool inDetailsRange) void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
@@ -159,7 +171,8 @@ namespace Content.Server.Morgue.Components
else if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) else if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
{ {
message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents")); message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents"));
} else }
else
{ {
message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty")); message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty"));
} }

View File

@@ -1,10 +1,7 @@
using Content.Shared.Audio; using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Movement.Components namespace Content.Server.Movement.Components
@@ -15,23 +12,16 @@ namespace Content.Server.Movement.Components
[RegisterComponent] [RegisterComponent]
public class FootstepModifierComponent : Component public class FootstepModifierComponent : Component
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _footstepRandom = default!;
/// <inheritdoc /> /// <inheritdoc />
public override string Name => "FootstepModifier"; public override string Name => "FootstepModifier";
[DataField("footstepSoundCollection")] [DataField("footstepSoundCollection")]
public string? _soundCollectionName; public SoundSpecifier _soundCollection = default!;
public void PlayFootstep() public void PlayFootstep()
{ {
if (!string.IsNullOrWhiteSpace(_soundCollectionName)) if (_soundCollection.TryGetSound(out var footstepSound))
{ SoundSystem.Play(Filter.Pvs(Owner), footstepSound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f));
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollectionName);
var file = _footstepRandom.Pick(soundCollection.PickFiles);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f));
}
} }
} }
} }

View File

@@ -1,6 +1,7 @@
using Content.Server.Chemistry.Components; using Content.Server.Chemistry.Components;
using Content.Server.Fluids.Components; using Content.Server.Fluids.Components;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Sound;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -19,10 +20,13 @@ namespace Content.Server.Nutrition.Components
[DataField("paralyzeTime")] [DataField("paralyzeTime")]
public float ParalyzeTime { get; set; } = 1f; public float ParalyzeTime { get; set; } = 1f;
[DataField("sound")]
private SoundSpecifier _sound = new SoundCollectionSpecifier("desacration");
public void PlaySound() public void PlaySound()
{ {
SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("desecration"), Owner, if(_sound.TryGetSound(out var sound))
AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.125f));
} }
void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs) void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs)

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.Components;
using Content.Shared.Sound;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -46,7 +47,7 @@ namespace Content.Server.Nutrition.Components
[ViewVariables] [ViewVariables]
[DataField("useSound")] [DataField("useSound")]
private string _useSound = "/Audio/Items/drink.ogg"; private SoundSpecifier _useSound = new SoundPathSpecifier("/Audio/Items/drink.ogg");
[ViewVariables] [ViewVariables]
[DataField("isOpen")] [DataField("isOpen")]
@@ -75,11 +76,11 @@ namespace Content.Server.Nutrition.Components
public bool Empty => Owner.GetComponentOrNull<ISolutionInteractionsComponent>()?.DrainAvailable <= 0; public bool Empty => Owner.GetComponentOrNull<ISolutionInteractionsComponent>()?.DrainAvailable <= 0;
[DataField("openSounds")] [DataField("openSounds")]
private string _soundCollection = "canOpenSounds"; private SoundSpecifier _openSounds = new SoundCollectionSpecifier("canOpenSounds");
[DataField("pressurized")] [DataField("pressurized")]
private bool _pressurized = default; private bool _pressurized = default;
[DataField("burstSound")] [DataField("burstSound")]
private string _burstSound = "/Audio/Effects/flash_bang.ogg"; private SoundSpecifier _burstSound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg");
protected override void Initialize() protected override void Initialize()
{ {
@@ -127,10 +128,9 @@ namespace Content.Server.Nutrition.Components
if (!Opened) if (!Opened)
{ {
//Do the opening stuff like playing the sounds. //Do the opening stuff like playing the sounds.
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollection); if(_openSounds.TryGetSound(out var openSound))
var file = _random.Pick(soundCollection.PickFiles); SoundSystem.Play(Filter.Pvs(args.User), openSound, args.User, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(args.User), file, args.User, AudioParams.Default);
Opened = true; Opened = true;
return false; return false;
} }
@@ -220,9 +220,9 @@ namespace Content.Server.Nutrition.Components
return false; return false;
} }
if (!string.IsNullOrEmpty(_useSound)) if (_useSound.TryGetSound(out var useSound))
{ {
SoundSystem.Play(Filter.Pvs(target), _useSound, target, AudioParams.Default.WithVolume(-2f)); SoundSystem.Play(Filter.Pvs(target), useSound, target, AudioParams.Default.WithVolume(-2f));
} }
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp")); target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp"));
@@ -254,8 +254,8 @@ namespace Content.Server.Nutrition.Components
var solution = interactions.Drain(interactions.DrainAvailable); var solution = interactions.Drain(interactions.DrainAvailable);
solution.SpillAt(Owner, "PuddleSmear"); solution.SpillAt(Owner, "PuddleSmear");
SoundSystem.Play(Filter.Pvs(Owner), _burstSound, Owner, if(_burstSound.TryGetSound(out var burstSound))
AudioParams.Default.WithVolume(-4)); SoundSystem.Play(Filter.Pvs(Owner), burstSound, Owner, AudioParams.Default.WithVolume(-4));
} }
} }
} }

View File

@@ -13,6 +13,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
@@ -30,7 +31,7 @@ namespace Content.Server.Nutrition.Components
{ {
public override string Name => "Food"; public override string Name => "Food";
[ViewVariables] [DataField("useSound")] protected virtual string? UseSound { get; set; } = "/Audio/Items/eatfood.ogg"; [ViewVariables] [DataField("useSound")] protected virtual SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/Items/eatfood.ogg");
[ViewVariables] [DataField("trash", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] protected virtual string? TrashPrototype { get; set; } [ViewVariables] [DataField("trash", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] protected virtual string? TrashPrototype { get; set; }
@@ -160,9 +161,9 @@ namespace Content.Server.Nutrition.Components
firstStomach.TryTransferSolution(split); firstStomach.TryTransferSolution(split);
if (UseSound != null) if (UseSound.TryGetSound(out var useSound))
{ {
SoundSystem.Play(Filter.Pvs(trueTarget), UseSound, trueTarget, AudioParams.Default.WithVolume(-1f)); SoundSystem.Play(Filter.Pvs(trueTarget), useSound, trueTarget, AudioParams.Default.WithVolume(-1f));
} }
trueTarget.PopupMessage(user, Loc.GetString("food-nom")); trueTarget.PopupMessage(user, Loc.GetString("food-nom"));

View File

@@ -5,6 +5,7 @@ using Content.Server.Items;
using Content.Shared.Chemistry.Reagent; using Content.Shared.Chemistry.Reagent;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -27,7 +28,7 @@ namespace Content.Server.Nutrition.Components
private string _slice = string.Empty; private string _slice = string.Empty;
[DataField("sound")] [ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] [ViewVariables(VVAccess.ReadWrite)]
private string _sound = "/Audio/Items/Culinary/chop.ogg"; private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Items/Culinary/chop.ogg");
[DataField("count")] [ViewVariables(VVAccess.ReadWrite)] [DataField("count")] [ViewVariables(VVAccess.ReadWrite)]
private ushort _totalCount = 5; private ushort _totalCount = 5;
@@ -66,8 +67,9 @@ namespace Content.Server.Nutrition.Components
} }
} }
SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates, if(_sound.TryGetSound(out var sound))
AudioParams.Default.WithVolume(-2)); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates,
AudioParams.Default.WithVolume(-2));
Count--; Count--;
if (Count < 1) if (Count < 1)

View File

@@ -3,6 +3,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -47,7 +48,7 @@ namespace Content.Server.Nutrition.Components
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("breakSound")] [DataField("breakSound")]
private string? _breakSound = "/Audio/Items/snap.ogg"; private SoundSpecifier _breakSound = new SoundPathSpecifier("/Audio/Items/snap.ogg");
public void AddType(UtensilType type) public void AddType(UtensilType type)
{ {
@@ -71,9 +72,9 @@ namespace Content.Server.Nutrition.Components
internal void TryBreak(IEntity user) internal void TryBreak(IEntity user)
{ {
if (_breakSound != null && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance)) if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
{ {
SoundSystem.Play(Filter.Pvs(user), _breakSound, user, AudioParams.Default.WithVolume(-2f)); SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f));
Owner.Delete(); Owner.Delete();
} }
} }

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.PDA; using Content.Shared.PDA;
using Content.Shared.Sound;
using Content.Shared.Tag; using Content.Shared.Tag;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -59,6 +60,10 @@ namespace Content.Server.PDA
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(PDAUiKey.Key); [ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(PDAUiKey.Key);
[DataField("insertIdSound")] private SoundSpecifier _insertIdSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg");
[DataField("toggleFlashlightSound")] private SoundSpecifier _toggleFlashlightSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[DataField("ejectIdSound")] private SoundSpecifier _ejectIdSound = new SoundPathSpecifier("/Audio/Machines/id_swipe.ogg");
public PDAComponent() public PDAComponent()
{ {
_accessSet = new PdaAccessSet(this); _accessSet = new PdaAccessSet(this);
@@ -301,7 +306,8 @@ namespace Content.Server.PDA
{ {
_idSlot.Insert(card.Owner); _idSlot.Insert(card.Owner);
ContainedID = card; ContainedID = card;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg", Owner); if(_insertIdSound.TryGetSound(out var insertIdSound))
SoundSystem.Play(Filter.Pvs(Owner), insertIdSound, Owner);
} }
/// <summary> /// <summary>
@@ -330,7 +336,8 @@ namespace Content.Server.PDA
_lightOn = !_lightOn; _lightOn = !_lightOn;
light.Enabled = _lightOn; light.Enabled = _lightOn;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/flashlight_toggle.ogg", Owner); if(_toggleFlashlightSound.TryGetSound(out var toggleFlashlightSound))
SoundSystem.Play(Filter.Pvs(Owner), toggleFlashlightSound, Owner);
UpdatePDAUserInterface(); UpdatePDAUserInterface();
} }
@@ -349,7 +356,8 @@ namespace Content.Server.PDA
hands.PutInHandOrDrop(cardItemComponent); hands.PutInHandOrDrop(cardItemComponent);
ContainedID = null; ContainedID = null;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/id_swipe.ogg", Owner); if(_ejectIdSound.TryGetSound(out var ejectIdSound))
SoundSystem.Play(Filter.Pvs(Owner), ejectIdSound, Owner);
UpdatePDAUserInterface(); UpdatePDAUserInterface();
} }

View File

@@ -9,6 +9,7 @@ using Content.Shared.Inventory;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Sound;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -154,38 +155,37 @@ namespace Content.Server.Physics.Controllers
// If the coordinates have a FootstepModifier component // If the coordinates have a FootstepModifier component
// i.e. component that emit sound on footsteps emit that sound // i.e. component that emit sound on footsteps emit that sound
string? soundCollectionName = null; string? soundToPlay = null;
foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices)) foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices))
{ {
if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep)) if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep) &&
footstep._soundCollection.TryGetSound(out var footstepSound))
{ {
soundCollectionName = footstep._soundCollectionName; soundToPlay = footstepSound;
break; break;
} }
} }
// if there is no FootstepModifierComponent, determine sound based on tiles // if there is no FootstepModifierComponent, determine sound based on tiles
if (soundCollectionName == null) if (soundToPlay == null)
{ {
// Walking on a tile. // Walking on a tile.
var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];
if (string.IsNullOrEmpty(def.FootstepSounds)) if (def.FootstepSounds.TryGetSound(out var footstepSound))
{ {
// Nothing to play, oh well. soundToPlay = footstepSound;
return; return;
} }
soundCollectionName = def.FootstepSounds;
} }
if (!_prototypeManager.TryIndex(soundCollectionName, out SoundCollectionPrototype? soundCollection)) if (string.IsNullOrWhiteSpace(soundToPlay))
{ {
Logger.ErrorS("sound", $"Unable to find sound collection for {soundCollectionName}"); Logger.ErrorS("sound", $"Unable to find sound in {nameof(PlayFootstepSound)}");
return; return;
} }
SoundSystem.Play( SoundSystem.Play(
Filter.Pvs(coordinates), Filter.Pvs(coordinates),
_robustRandom.Pick(soundCollection.PickFiles), soundToPlay,
mover.Transform.Coordinates, mover.Transform.Coordinates,
sprinting ? AudioParams.Default.WithVolume(0.75f) : null); sprinting ? AudioParams.Default.WithVolume(0.75f) : null);
} }

View File

@@ -4,10 +4,12 @@ using Content.Shared.Audio;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.Plants.Components namespace Content.Server.Plants.Components
@@ -18,6 +20,7 @@ namespace Content.Server.Plants.Components
public override string Name => "PottedPlantHide"; public override string Name => "PottedPlantHide";
[ViewVariables] private SecretStashComponent _secretStash = default!; [ViewVariables] private SecretStashComponent _secretStash = default!;
[DataField("rustleSound")] private SoundSpecifier _rustleSound = new SoundPathSpecifier("/Audio/Effects/plant_rustle.ogg");
protected override void Initialize() protected override void Initialize()
{ {
@@ -46,7 +49,8 @@ namespace Content.Server.Plants.Components
private void Rustle() private void Rustle()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/plant_rustle.ogg", Owner, AudioHelpers.WithVariation(0.25f)); if(_rustleSound.TryGetSound(out var rustleSound))
SoundSystem.Play(Filter.Pvs(Owner), rustleSound, Owner, AudioHelpers.WithVariation(0.25f));
} }
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using Content.Server.Explosion; using Content.Server.Explosion;
using Content.Shared.Pointing.Components; using Content.Shared.Pointing.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -41,6 +42,9 @@ namespace Content.Server.Pointing.Components
[DataField("chasingTime")] [DataField("chasingTime")]
private float _chasingTime = 1; private float _chasingTime = 1;
[DataField("explosionSound")]
private SoundSpecifier _explosionSound = new SoundPathSpecifier("/Audio/Effects/explosion.ogg");
private IEntity? RandomNearbyPlayer() private IEntity? RandomNearbyPlayer()
{ {
var players = _playerManager var players = _playerManager
@@ -120,7 +124,8 @@ namespace Content.Server.Pointing.Components
} }
Owner.SpawnExplosion(0, 2, 1, 1); Owner.SpawnExplosion(0, 2, 1, 1);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/explosion.ogg", Owner); if(_explosionSound.TryGetSound(out var explosionSound))
SoundSystem.Play(Filter.Pvs(Owner), explosionSound, Owner);
Owner.Delete(); Owner.Delete();
} }

View File

@@ -2,6 +2,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Portal.Components; using Content.Shared.Portal.Components;
using Content.Shared.Sound;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -28,8 +29,8 @@ namespace Content.Server.Portal.Components
[ViewVariables(VVAccess.ReadWrite)] [DataField("individual_cooldown")] private float _individualPortalCooldown = 2.1f; [ViewVariables(VVAccess.ReadWrite)] [DataField("individual_cooldown")] private float _individualPortalCooldown = 2.1f;
[ViewVariables] [DataField("overall_cooldown")] private float _overallPortalCooldown = 2.0f; [ViewVariables] [DataField("overall_cooldown")] private float _overallPortalCooldown = 2.0f;
[ViewVariables] private bool _onCooldown; [ViewVariables] private bool _onCooldown;
[ViewVariables] [DataField("departure_sound")] private string _departureSound = "/Audio/Effects/teleport_departure.ogg"; [ViewVariables] [DataField("departure_sound")] private SoundSpecifier _departureSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
[ViewVariables] [DataField("arrival_sound")] private string _arrivalSound = "/Audio/Effects/teleport_arrival.ogg"; [ViewVariables] [DataField("arrival_sound")] private SoundSpecifier _arrivalSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
public readonly List<IEntity> ImmuneEntities = new(); // K public readonly List<IEntity> ImmuneEntities = new(); // K
[ViewVariables(VVAccess.ReadWrite)] [DataField("alive_time")] private float _aliveTime = 10f; [ViewVariables(VVAccess.ReadWrite)] [DataField("alive_time")] private float _aliveTime = 10f;
@@ -143,9 +144,11 @@ namespace Content.Server.Portal.Components
// Departure // Departure
// Do we need to rate-limit sounds to stop ear BLAST? // Do we need to rate-limit sounds to stop ear BLAST?
SoundSystem.Play(Filter.Pvs(entity), _departureSound, entity.Transform.Coordinates); if(_departureSound.TryGetSound(out var departureSound))
SoundSystem.Play(Filter.Pvs(entity), departureSound, entity.Transform.Coordinates);
entity.Transform.Coordinates = position; entity.Transform.Coordinates = position;
SoundSystem.Play(Filter.Pvs(entity), _arrivalSound, entity.Transform.Coordinates); if(_arrivalSound.TryGetSound(out var arrivalSound))
SoundSystem.Play(Filter.Pvs(entity), arrivalSound, entity.Transform.Coordinates);
TryChangeState(PortalState.RecentlyTeleported); TryChangeState(PortalState.RecentlyTeleported);
// To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal // To stop spam teleporting. Could potentially look at adding a timer to flush this from the portal

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Portal.Components; using Content.Shared.Portal.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -38,9 +39,9 @@ namespace Content.Server.Portal.Components
[ViewVariables] private ItemTeleporterState _state; [ViewVariables] private ItemTeleporterState _state;
[DataField("teleporter_type")] [DataField("teleporter_type")]
[ViewVariables] private TeleporterType _teleporterType = TeleporterType.Random; [ViewVariables] private TeleporterType _teleporterType = TeleporterType.Random;
[ViewVariables] [DataField("departure_sound")] private string _departureSound = "/Audio/Effects/teleport_departure.ogg"; [ViewVariables] [DataField("departure_sound")] private SoundSpecifier _departureSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
[ViewVariables] [DataField("arrival_sound")] private string _arrivalSound = "/Audio/Effects/teleport_arrival.ogg"; [ViewVariables] [DataField("arrival_sound")] private SoundSpecifier _arrivalSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
[ViewVariables] [DataField("cooldown_sound")] private string? _cooldownSound = default; [ViewVariables] [DataField("cooldown_sound")] private SoundSpecifier _cooldownSound = default!;
// If the direct OR random teleport will try to avoid hitting collidables // If the direct OR random teleport will try to avoid hitting collidables
[DataField("avoid_walls")] [ViewVariables] [DataField("avoid_walls")] [ViewVariables]
private bool _avoidCollidable = true; private bool _avoidCollidable = true;
@@ -124,9 +125,9 @@ namespace Content.Server.Portal.Components
{ {
SetState(ItemTeleporterState.Cooldown); SetState(ItemTeleporterState.Cooldown);
Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off)); Owner.SpawnTimer(TimeSpan.FromSeconds(_chargeTime + _cooldown), () => SetState(ItemTeleporterState.Off));
if (_cooldownSound != null) if (_cooldownSound.TryGetSound(out var cooldownSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), _cooldownSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), cooldownSound, Owner);
} }
} }
@@ -229,12 +230,14 @@ namespace Content.Server.Portal.Components
else else
{ {
// Departure // Departure
SoundSystem.Play(Filter.Pvs(user), _departureSound, user.Transform.Coordinates); if(_departureSound.TryGetSound(out var departureSound))
SoundSystem.Play(Filter.Pvs(user), departureSound, user.Transform.Coordinates);
// Arrival // Arrival
user.Transform.AttachToGridOrMap(); user.Transform.AttachToGridOrMap();
user.Transform.WorldPosition = vector; user.Transform.WorldPosition = vector;
SoundSystem.Play(Filter.Pvs(user), _arrivalSound, user.Transform.Coordinates); if(_arrivalSound.TryGetSound(out var arrivalSound))
SoundSystem.Play(Filter.Pvs(user), arrivalSound, user.Transform.Coordinates);
} }
} }
} }

View File

@@ -6,6 +6,7 @@ using Content.Server.UserInterface;
using Content.Shared.APC; using Content.Shared.APC;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -13,6 +14,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -28,6 +30,8 @@ namespace Content.Server.Power.Components
public bool MainBreakerEnabled { get; private set; } = true; public bool MainBreakerEnabled { get; private set; } = true;
[DataField("onReceiveMessageSound")] private SoundSpecifier _onReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
private ApcChargeState _lastChargeState; private ApcChargeState _lastChargeState;
private TimeSpan _lastChargeStateChange; private TimeSpan _lastChargeStateChange;
@@ -90,7 +94,8 @@ namespace Content.Server.Power.Components
Owner.GetComponent<PowerNetworkBatteryComponent>().CanDischarge = MainBreakerEnabled; Owner.GetComponent<PowerNetworkBatteryComponent>().CanDischarge = MainBreakerEnabled;
_uiDirty = true; _uiDirty = true;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f)); if(_onReceiveMessageSound.TryGetSound(out var onReceiveMessageSound))
SoundSystem.Play(Filter.Pvs(Owner), onReceiveMessageSound, Owner, AudioParams.Default.WithVolume(-2f));
} }
else else
{ {

View File

@@ -6,6 +6,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -63,7 +64,7 @@ namespace Content.Server.PowerCell.Components
/// <example>"/Audio/Items/pistol_magout.ogg"</example> /// <example>"/Audio/Items/pistol_magout.ogg"</example>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("cellRemoveSound")] [DataField("cellRemoveSound")]
public string? CellRemoveSound { get; set; } = "/Audio/Items/pistol_magin.ogg"; public SoundSpecifier CellRemoveSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magin.ogg");
/// <summary> /// <summary>
/// File path to a sound file that should be played when a cell is inserted. /// File path to a sound file that should be played when a cell is inserted.
@@ -71,7 +72,7 @@ namespace Content.Server.PowerCell.Components
/// <example>"/Audio/Items/pistol_magin.ogg"</example> /// <example>"/Audio/Items/pistol_magin.ogg"</example>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("cellInsertSound")] [DataField("cellInsertSound")]
public string? CellInsertSound { get; set; } = "/Audio/Items/pistol_magout.ogg"; public SoundSpecifier CellInsertSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magout.ogg");
[ViewVariables] private ContainerSlot _cellContainer = default!; [ViewVariables] private ContainerSlot _cellContainer = default!;
@@ -144,9 +145,9 @@ namespace Content.Server.PowerCell.Components
cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates; cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
} }
if (playSound && CellRemoveSound != null) if (playSound && CellRemoveSound.TryGetSound(out var cellRemoveSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), cellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f));
} }
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false); Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false);
@@ -167,9 +168,9 @@ namespace Content.Server.PowerCell.Components
if (cellComponent.CellSize != SlotSize) return false; if (cellComponent.CellSize != SlotSize) return false;
if (!_cellContainer.Insert(cell)) return false; if (!_cellContainer.Insert(cell)) return false;
//Dirty(); //Dirty();
if (playSound && CellInsertSound != null) if (playSound && CellInsertSound.TryGetSound(out var cellInsertSound))
{ {
SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound, Owner, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), cellInsertSound, Owner, AudioHelpers.WithVariation(0.125f));
} }
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false); Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false);

View File

@@ -1,6 +1,7 @@
using System; using System;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -50,7 +51,7 @@ namespace Content.Server.Projectiles.Components
[DataField("impactFlash")] [DataField("impactFlash")]
private string? _impactFlash; private string? _impactFlash;
[DataField("soundHitWall")] [DataField("soundHitWall")]
private string _soundHitWall = "/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg"; private SoundSpecifier _soundHitWall = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg");
public void FireEffects(IEntity user, float distance, Angle angle, IEntity? hitEntity = null) public void FireEffects(IEntity user, float distance, Angle angle, IEntity? hitEntity = null)
{ {
@@ -85,7 +86,8 @@ namespace Content.Server.Projectiles.Components
// TODO: No wall component so ? // TODO: No wall component so ?
var offset = angle.ToVec().Normalized / 2; var offset = angle.ToVec().Normalized / 2;
var coordinates = user.Transform.Coordinates.Offset(offset); var coordinates = user.Transform.Coordinates.Offset(offset);
SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall, coordinates); if(_soundHitWall.TryGetSound(out var soundHitWall))
SoundSystem.Play(Filter.Pvs(coordinates), soundHitWall, coordinates);
} }
Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () =>

View File

@@ -1,8 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Camera; using Content.Server.Camera;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Components; using Content.Shared.Damage.Components;
using Content.Shared.Projectiles; using Content.Shared.Projectiles;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Collision; using Robust.Shared.Physics.Collision;
@@ -33,9 +34,7 @@ namespace Content.Server.Projectiles.Components
// Get that juicy FPS hit sound // Get that juicy FPS hit sound
[DataField("soundHit")] [DataField("soundHit")]
private string? _soundHit = default; private SoundSpecifier _soundHit = default!;
[DataField("soundHitSpecies")]
private string? _soundHitSpecies = default;
private bool _damagedEntity; private bool _damagedEntity;
@@ -64,13 +63,9 @@ namespace Content.Server.Projectiles.Components
var coordinates = otherFixture.Body.Owner.Transform.Coordinates; var coordinates = otherFixture.Body.Owner.Transform.Coordinates;
var playerFilter = Filter.Pvs(coordinates); var playerFilter = Filter.Pvs(coordinates);
if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHitSpecies != null) if (otherFixture.Body.Owner.TryGetComponent(out IDamageableComponent? damage) && _soundHit.TryGetSound(out var soundHit))
{ {
SoundSystem.Play(playerFilter, _soundHitSpecies, coordinates); SoundSystem.Play(playerFilter, soundHit, coordinates);
}
else if (_soundHit != null)
{
SoundSystem.Play(playerFilter, _soundHit, coordinates);
} }
if (damage != null) if (damage != null)

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -38,6 +39,12 @@ namespace Content.Server.RCD.Components
[ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] private float _delay = 2f; [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] private float _delay = 2f;
private DoAfterSystem _doAfterSystem = default!; private DoAfterSystem _doAfterSystem = default!;
[DataField("swapModeSound")]
private SoundSpecifier _swapModeSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg");
[DataField("successSound")]
private SoundSpecifier _successSound = new SoundPathSpecifier("/Audio/Items/deconstruct.ogg");
///Enum to store the different mode states for clarity. ///Enum to store the different mode states for clarity.
private enum RcdMode private enum RcdMode
{ {
@@ -70,8 +77,9 @@ namespace Content.Server.RCD.Components
public void SwapMode(UseEntityEventArgs eventArgs) public void SwapMode(UseEntityEventArgs eventArgs)
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/genhit.ogg", Owner); if(_swapModeSound.TryGetSound(out var swapModeSound))
int mode = (int) _mode; //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default) SoundSystem.Play(Filter.Pvs(Owner), swapModeSound, Owner);
var mode = (int) _mode; //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)
mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state mode = (++mode) % _modes.Length; //Then, do a rollover on the value so it doesnt hit an invalid state
_mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it. _mode = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it.
Owner.PopupMessage(eventArgs.User, Owner.PopupMessage(eventArgs.User,
@@ -155,7 +163,8 @@ namespace Content.Server.RCD.Components
return true; //I don't know why this would happen, but sure I guess. Get out of here invalid state! return true; //I don't know why this would happen, but sure I guess. Get out of here invalid state!
} }
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/deconstruct.ogg", Owner); if(_successSound.TryGetSound(out var successSound))
SoundSystem.Play(Filter.Pvs(Owner), successSound, Owner);
_ammo--; _ammo--;
return true; return true;
} }

View File

@@ -1,5 +1,6 @@
using System; using System;
using Content.Shared.Radiation; using Content.Shared.Radiation;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -57,7 +58,7 @@ namespace Content.Server.Radiation
} }
} }
[DataField("sound")] public string? Sound { get; set; } = "/Audio/Weapons/Guns/Gunshots/laser3.ogg"; [DataField("sound")] public SoundSpecifier Sound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/Guns/Gunshots/laser3.ogg");
[DataField("range")] [DataField("range")]
public override float Range public override float Range
@@ -92,8 +93,8 @@ namespace Content.Server.Radiation
_endTime = currentTime + TimeSpan.FromSeconds(_duration); _endTime = currentTime + TimeSpan.FromSeconds(_duration);
} }
if(!string.IsNullOrEmpty(Sound)) if(Sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), Sound, Owner.Transform.Coordinates); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates);
Dirty(); Dirty();
} }

View File

@@ -1,5 +1,6 @@
using System.Linq; using System.Linq;
using Content.Shared.Radiation; using Content.Shared.Radiation;
using Content.Shared.Sound;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -19,7 +20,7 @@ namespace Content.Server.Radiation
bool decay = true, bool decay = true,
float minPulseLifespan = 0.8f, float minPulseLifespan = 0.8f,
float maxPulseLifespan = 2.5f, float maxPulseLifespan = 2.5f,
string? sound = null) SoundSpecifier sound = default!)
{ {
var radiationEntity = EntityManager.SpawnEntity(RadiationPrototype, coordinates); var radiationEntity = EntityManager.SpawnEntity(RadiationPrototype, coordinates);
var radiation = radiationEntity.GetComponent<RadiationPulseComponent>(); var radiation = radiationEntity.GetComponent<RadiationPulseComponent>();

View File

@@ -5,6 +5,7 @@ using Content.Shared.Audio;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Research.Components; using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes; using Content.Shared.Research.Prototypes;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -13,6 +14,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.Research.Components namespace Content.Server.Research.Components
@@ -24,7 +26,8 @@ namespace Content.Server.Research.Components
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
private const string SoundCollectionName = "keyboard"; [DataField("sound")]
private SoundSpecifier _soundCollectionName = new SoundCollectionSpecifier("keyboard");
[ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered; [ViewVariables] private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
@@ -123,9 +126,8 @@ namespace Content.Server.Research.Components
private void PlayKeyboardSound() private void PlayKeyboardSound()
{ {
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(SoundCollectionName); if (_soundCollectionName.TryGetSound(out var sound))
var file = _random.Pick(soundCollection.PickFiles); SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(Owner), file,Owner,AudioParams.Default);
} }
} }
} }

View File

@@ -127,7 +127,7 @@ namespace Content.Server.RoundEnd
private void EndRound() private void EndRound()
{ {
OnRoundEndCountdownFinished?.Invoke(); OnRoundEndCountdownFinished?.Invoke();
var gameTicker = EntitySystem.Get<GameTicker>(); var gameTicker = Get<GameTicker>();
gameTicker.EndRound(); gameTicker.EndRound();
_chatManager.DispatchServerAnnouncement(Loc.GetString("round-end-system-round-restart-eta-announcement", ("seconds", RestartRoundTime))); _chatManager.DispatchServerAnnouncement(Loc.GetString("round-end-system-round-restart-eta-announcement", ("seconds", RestartRoundTime)));

View File

@@ -10,6 +10,7 @@ using Content.Shared.Interaction;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Singularity.Components; using Content.Shared.Singularity.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -56,7 +57,7 @@ namespace Content.Server.Singularity.Components
[ViewVariables(VVAccess.ReadWrite)] private int _fireShotCounter; [ViewVariables(VVAccess.ReadWrite)] private int _fireShotCounter;
[ViewVariables(VVAccess.ReadWrite)] [DataField("fireSound")] private string _fireSound = "/Audio/Weapons/emitter.ogg"; [ViewVariables(VVAccess.ReadWrite)] [DataField("fireSound")] private SoundSpecifier _fireSound = new SoundPathSpecifier("/Audio/Weapons/emitter.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("boltType")] private string _boltType = "EmitterBolt"; [ViewVariables(VVAccess.ReadWrite)] [DataField("boltType")] private string _boltType = "EmitterBolt";
[ViewVariables(VVAccess.ReadWrite)] [DataField("powerUseActive")] private int _powerUseActive = 500; [ViewVariables(VVAccess.ReadWrite)] [DataField("powerUseActive")] private int _powerUseActive = 500;
[ViewVariables(VVAccess.ReadWrite)] [DataField("fireBurstSize")] private int _fireBurstSize = 3; [ViewVariables(VVAccess.ReadWrite)] [DataField("fireBurstSize")] private int _fireBurstSize = 3;
@@ -227,8 +228,9 @@ namespace Content.Server.Singularity.Components
// TODO: Move to projectile's code. // TODO: Move to projectile's code.
Timer.Spawn(3000, () => projectile.Delete()); Timer.Spawn(3000, () => projectile.Delete());
SoundSystem.Play(Filter.Pvs(Owner), _fireSound, Owner, if(_fireSound.TryGetSound(out var fireSound))
AudioHelpers.WithVariation(Variation).WithVolume(Volume).WithMaxDistance(Distance)); SoundSystem.Play(Filter.Pvs(Owner), fireSound, Owner,
AudioHelpers.WithVariation(Variation).WithVolume(Volume).WithMaxDistance(Distance));
} }
private void UpdateAppearance() private void UpdateAppearance()

View File

@@ -1,6 +1,7 @@
#nullable enable #nullable enable
using Content.Shared.Singularity; using Content.Shared.Singularity;
using Content.Shared.Singularity.Components; using Content.Shared.Singularity.Components;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -8,6 +9,7 @@ using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics; using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Players; using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -69,6 +71,10 @@ namespace Content.Server.Singularity.Components
private IPlayingAudioStream? _playingSound; private IPlayingAudioStream? _playingSound;
[DataField("singularityFormingSound")] private SoundSpecifier _singularityFormingSound = new SoundPathSpecifier("/Audio/Effects/singularity_form.ogg");
[DataField("singularitySound")] private SoundSpecifier _singularitySound = new SoundPathSpecifier("/Audio/Effects/singularity.ogg");
[DataField("singularityCollapsingSound")] private SoundSpecifier _singularityCollapsingSound = new SoundPathSpecifier("/Audio/Effects/singularity_collapse.ogg");
public override ComponentState GetComponentState(ICommonSession player) public override ComponentState GetComponentState(ICommonSession player)
{ {
return new SingularityComponentState(Level); return new SingularityComponentState(Level);
@@ -84,8 +90,9 @@ namespace Content.Server.Singularity.Components
audioParams.Loop = true; audioParams.Loop = true;
audioParams.MaxDistance = 20f; audioParams.MaxDistance = 20f;
audioParams.Volume = 5; audioParams.Volume = 5;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_form.ogg", Owner); if(_singularityFormingSound.TryGetSound(out var singuloFormingSound))
Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity.ogg", Owner, audioParams)); SoundSystem.Play(Filter.Pvs(Owner), singuloFormingSound, Owner);
Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams));
_singularitySystem.ChangeSingularityLevel(this, 1); _singularitySystem.ChangeSingularityLevel(this, 1);
} }
@@ -138,7 +145,8 @@ namespace Content.Server.Singularity.Components
protected override void OnRemove() protected override void OnRemove()
{ {
_playingSound?.Stop(); _playingSound?.Stop();
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates); if(_singularityCollapsingSound.TryGetSound(out var singuloCollapseSound))
SoundSystem.Play(Filter.Pvs(Owner), singuloCollapseSound, Owner.Transform.Coordinates);
base.OnRemove(); base.OnRemove();
} }
} }

View File

@@ -30,22 +30,15 @@ namespace Content.Server.Sound
private void HandleEmitSoundOn(BaseEmitSoundComponent component) private void HandleEmitSoundOn(BaseEmitSoundComponent component)
{ {
var soundName = component.Sound.GetSound(); if (component.Sound.TryGetSound(out var soundName))
{
if (!string.IsNullOrWhiteSpace(soundName)) SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
{
PlaySingleSound(soundName, component);
} }
else else
{ {
Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play."); Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play.");
} }
} }
private static void PlaySingleSound(string soundName, BaseEmitSoundComponent component)
{
SoundSystem.Play(Filter.Pvs(component.Owner), soundName, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
}
} }
} }

View File

@@ -1,6 +1,7 @@
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;

View File

@@ -1,11 +1,13 @@
using System.Linq;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using System.Linq;
namespace Content.Server.Storage.Components namespace Content.Server.Storage.Components
{ {
@@ -19,6 +21,9 @@ namespace Content.Server.Storage.Components
public override string Name => "CursedEntityStorage"; public override string Name => "CursedEntityStorage";
[DataField("cursedSound")] private SoundSpecifier _cursedSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
[DataField("cursedLockerSound")] private SoundSpecifier _cursedLockerSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
protected override void CloseStorage() protected override void CloseStorage()
{ {
base.CloseStorage(); base.CloseStorage();
@@ -46,8 +51,10 @@ namespace Content.Server.Storage.Components
locker.Insert(entity); locker.Insert(entity);
} }
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/teleport_departure.ogg", Owner, AudioHelpers.WithVariation(0.125f)); if(_cursedSound.TryGetSound(out var cursedSound))
SoundSystem.Play(Filter.Pvs(lockerEnt), "/Audio/Effects/teleport_arrival.ogg", lockerEnt, AudioHelpers.WithVariation(0.125f)); SoundSystem.Play(Filter.Pvs(Owner), cursedSound, Owner, AudioHelpers.WithVariation(0.125f));
if(_cursedLockerSound.TryGetSound(out var cursedLockerSound))
SoundSystem.Play(Filter.Pvs(lockerEnt), cursedLockerSound, lockerEnt, AudioHelpers.WithVariation(0.125f));
} }
} }
} }

View File

@@ -14,6 +14,7 @@ using Content.Shared.Item;
using Content.Shared.Movement; using Content.Shared.Movement;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Tool; using Content.Shared.Tool;
using Content.Shared.Verbs; using Content.Shared.Verbs;
@@ -76,10 +77,10 @@ namespace Content.Server.Storage.Components
private bool _isWeldedShut; private bool _isWeldedShut;
[DataField("closeSound")] [DataField("closeSound")]
private string _closeSound = "/Audio/Machines/closetclose.ogg"; private SoundSpecifier _closeSound = new SoundPathSpecifier("/Audio/Machines/closetclose.ogg");
[DataField("openSound")] [DataField("openSound")]
private string _openSound = "/Audio/Machines/closetopen.ogg"; private SoundSpecifier _openSound = new SoundPathSpecifier("/Audio/Machines/closetopen.ogg");
[ViewVariables] [ViewVariables]
protected Container Contents = default!; protected Container Contents = default!;
@@ -219,7 +220,8 @@ namespace Content.Server.Storage.Components
} }
ModifyComponents(); ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _closeSound, Owner); if(_closeSound.TryGetSound(out var closeSound))
SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner);
_lastInternalOpenAttempt = default; _lastInternalOpenAttempt = default;
} }
@@ -228,7 +230,8 @@ namespace Content.Server.Storage.Components
Open = true; Open = true;
EmptyContents(); EmptyContents();
ModifyComponents(); ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _openSound, Owner); if(_openSound.TryGetSound(out var openSound))
SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner);
} }
private void UpdateAppearance() private void UpdateAppearance()

View File

@@ -1,8 +1,8 @@
using Content.Server.Access.Components; using Content.Server.Access.Components;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -25,6 +25,9 @@ namespace Content.Server.Storage.Components
[DataField("locked")] [DataField("locked")]
private bool _locked = true; private bool _locked = true;
[DataField("unlockSound")] private SoundSpecifier _unlockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg");
[DataField("lockSound")] private SoundSpecifier _lockSound = new SoundPathSpecifier("/Audio/Machines/door_lock_on.ogg");
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public bool Locked public bool Locked
{ {
@@ -100,7 +103,8 @@ namespace Content.Server.Storage.Components
if (!CheckAccess(user)) return; if (!CheckAccess(user)) return;
Locked = false; Locked = false;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/door_lock_off.ogg", Owner, AudioParams.Default.WithVolume(-5)); if(_unlockSound.TryGetSound(out var unlockSound))
SoundSystem.Play(Filter.Pvs(Owner), unlockSound, Owner, AudioParams.Default.WithVolume(-5));
} }
private void DoLock(IEntity user) private void DoLock(IEntity user)
@@ -108,7 +112,8 @@ namespace Content.Server.Storage.Components
if (!CheckAccess(user)) return; if (!CheckAccess(user)) return;
Locked = true; Locked = true;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/door_lock_on.ogg", Owner, AudioParams.Default.WithVolume(-5)); if(_lockSound.TryGetSound(out var lockSound))
SoundSystem.Play(Filter.Pvs(Owner), lockSound, Owner, AudioParams.Default.WithVolume(-5));
} }
private bool CheckAccess(IEntity user) private bool CheckAccess(IEntity user)

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Item; using Content.Shared.Item;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Storage; using Content.Shared.Storage;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
@@ -59,7 +60,7 @@ namespace Content.Server.Storage.Components
public readonly HashSet<IPlayerSession> SubscribedSessions = new(); public readonly HashSet<IPlayerSession> SubscribedSessions = new();
[DataField("storageSoundCollection")] [DataField("storageSoundCollection")]
public string? StorageSoundCollection { get; set; } public SoundSpecifier StorageSoundCollection { get; set; } = default!;
[ViewVariables] [ViewVariables]
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities; public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
@@ -150,7 +151,7 @@ namespace Content.Server.Storage.Components
return; return;
} }
PlaySoundCollection(StorageSoundCollection); PlaySoundCollection();
EnsureInitialCalculated(); EnsureInitialCalculated();
Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it."); Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it.");
@@ -246,7 +247,7 @@ namespace Content.Server.Storage.Components
/// <param name="entity">The entity to open the UI for</param> /// <param name="entity">The entity to open the UI for</param>
public void OpenStorageUI(IEntity entity) public void OpenStorageUI(IEntity entity)
{ {
PlaySoundCollection(StorageSoundCollection); PlaySoundCollection();
EnsureInitialCalculated(); EnsureInitialCalculated();
var userSession = entity.GetComponent<ActorComponent>().PlayerSession; var userSession = entity.GetComponent<ActorComponent>().PlayerSession;
@@ -546,7 +547,7 @@ namespace Content.Server.Storage.Components
// If we picked up atleast one thing, play a sound and do a cool animation! // If we picked up atleast one thing, play a sound and do a cool animation!
if (successfullyInserted.Count>0) if (successfullyInserted.Count>0)
{ {
PlaySoundCollection(StorageSoundCollection); PlaySoundCollection();
SendNetworkMessage( SendNetworkMessage(
new AnimateInsertingEntitiesMessage( new AnimateInsertingEntitiesMessage(
successfullyInserted, successfullyInserted,
@@ -617,15 +618,10 @@ namespace Content.Server.Storage.Components
} }
} }
protected void PlaySoundCollection(string? name) private void PlaySoundCollection()
{ {
if (string.IsNullOrEmpty(name)) if(StorageSoundCollection.TryGetSound(out var sound))
{ SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default);
return;
}
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioParams.Default);
} }
} }
} }

View File

@@ -1,4 +1,5 @@
#nullable enable #nullable enable
using Content.Shared.Sound;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -31,5 +32,14 @@ namespace Content.Server.Stunnable.Components
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
[DataField("energyPerUse")] [DataField("energyPerUse")]
public float EnergyPerUse { get; set; } = 50; public float EnergyPerUse { get; set; } = 50;
[DataField("stunSound")]
public SoundSpecifier StunSound { get; set; } = new SoundPathSpecifier("/Audio/Weapons/egloves.ogg");
[DataField("sparksSound")]
public SoundSpecifier SparksSound { get; set; } = new SoundCollectionSpecifier("sparks");
[DataField("turnOnFailSound")]
public SoundSpecifier TurnOnFailSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/button.ogg");
} }
} }

View File

@@ -4,6 +4,7 @@ using Content.Server.Notification;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.MobState; using Content.Shared.MobState;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -12,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Stunnable.Components namespace Content.Server.Stunnable.Components
{ {
@@ -19,6 +21,8 @@ namespace Content.Server.Stunnable.Components
[ComponentReference(typeof(SharedStunnableComponent))] [ComponentReference(typeof(SharedStunnableComponent))]
public class StunnableComponent : SharedStunnableComponent, IDisarmedAct public class StunnableComponent : SharedStunnableComponent, IDisarmedAct
{ {
[DataField("stunAttemptSound")] private SoundSpecifier _stunAttemptSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
protected override void OnKnockdown() protected override void OnKnockdown()
{ {
EntitySystem.Get<StandingStateSystem>().Down(Owner); EntitySystem.Get<StandingStateSystem>().Down(Owner);
@@ -54,7 +58,8 @@ namespace Content.Server.Stunnable.Components
protected override void OnInteractHand() protected override void OnInteractHand()
{ {
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f)); if(_stunAttemptSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f));
} }
bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs) bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs)
@@ -69,8 +74,8 @@ namespace Content.Server.Stunnable.Components
if (source != null) if (source != null)
{ {
SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source, if (_stunAttemptSound.TryGetSound(out var sound))
AudioHelpers.WithVariation(0.025f)); SoundSystem.Play(Filter.Pvs(source), sound, source, AudioHelpers.WithVariation(0.025f));
if (target != null) if (target != null)
{ {
source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name),("target", target.Name))); source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name),("target", target.Name)));

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using Content.Server.Items; using Content.Server.Items;
using Content.Server.PowerCell.Components; using Content.Server.PowerCell.Components;
using Content.Server.Stunnable.Components; using Content.Server.Stunnable.Components;
@@ -119,7 +119,8 @@ namespace Content.Server.Stunnable
{ {
if (!entity.TryGetComponent(out StunnableComponent? stunnable) || !comp.Activated) return; if (!entity.TryGetComponent(out StunnableComponent? stunnable) || !comp.Activated) return;
SoundSystem.Play(Filter.Pvs(comp.Owner), "/Audio/Weapons/egloves.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.StunSound.TryGetSound(out var stunSound))
SoundSystem.Play(Filter.Pvs(comp.Owner), stunSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
if(!stunnable.SlowedDown) if(!stunnable.SlowedDown)
{ {
if(_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) if(_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown))
@@ -136,9 +137,11 @@ namespace Content.Server.Stunnable
} }
if (!comp.Owner.TryGetComponent<PowerCellSlotComponent>(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) return; if (!comp.Owner.TryGetComponent<PowerCellSlotComponent>(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse))
return;
SoundSystem.Play(Filter.Pvs(comp.Owner), AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.SparksSound.TryGetSound(out var sparksSound))
SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
TurnOff(comp); TurnOff(comp);
} }
@@ -152,7 +155,8 @@ namespace Content.Server.Stunnable
if (!comp.Owner.TryGetComponent<SpriteComponent>(out var sprite) || if (!comp.Owner.TryGetComponent<SpriteComponent>(out var sprite) ||
!comp.Owner.TryGetComponent<ItemComponent>(out var item)) return; !comp.Owner.TryGetComponent<ItemComponent>(out var item)) return;
SoundSystem.Play(Filter.Pvs(comp.Owner), AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.SparksSound.TryGetSound(out var sparksSound))
SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
item.EquippedPrefix = "off"; item.EquippedPrefix = "off";
// TODO stunbaton visualizer // TODO stunbaton visualizer
sprite.LayerSetState(0, "stunbaton_off"); sprite.LayerSetState(0, "stunbaton_off");
@@ -167,7 +171,8 @@ namespace Content.Server.Stunnable
} }
if (!comp.Owner.TryGetComponent<SpriteComponent>(out var sprite) || if (!comp.Owner.TryGetComponent<SpriteComponent>(out var sprite) ||
!comp.Owner.TryGetComponent<ItemComponent>(out var item)) return; !comp.Owner.TryGetComponent<ItemComponent>(out var item))
return;
var playerFilter = Filter.Pvs(comp.Owner); var playerFilter = Filter.Pvs(comp.Owner);
if (!comp.Owner.TryGetComponent<PowerCellSlotComponent>(out var slot)) if (!comp.Owner.TryGetComponent<PowerCellSlotComponent>(out var slot))
@@ -175,19 +180,22 @@ namespace Content.Server.Stunnable
if (slot.Cell == null) if (slot.Cell == null)
{ {
SoundSystem.Play(playerFilter, "/Audio/Machines/button.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
user.PopupMessage(Loc.GetString("comp-stunbaton-activated-missing-cell")); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-missing-cell"));
return; return;
} }
if (slot.Cell != null && slot.Cell.CurrentCharge < comp.EnergyPerUse) if (slot.Cell != null && slot.Cell.CurrentCharge < comp.EnergyPerUse)
{ {
SoundSystem.Play(playerFilter, "/Audio/Machines/button.ogg", comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound))
SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
user.PopupMessage(Loc.GetString("comp-stunbaton-activated-dead-cell")); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-dead-cell"));
return; return;
} }
SoundSystem.Play(playerFilter, AudioHelpers.GetRandomFileFromSoundCollection("sparks"), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); if(comp.SparksSound.TryGetSound(out var sparksSound))
SoundSystem.Play(playerFilter, sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f));
item.EquippedPrefix = "on"; item.EquippedPrefix = "on";
sprite.LayerSetState(0, "stunbaton_on"); sprite.LayerSetState(0, "stunbaton_on");

View File

@@ -5,6 +5,7 @@ using Content.Shared.Audio;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers; using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Sound;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -25,6 +26,8 @@ namespace Content.Server.Tiles
[DataField("outputs", customTypeSerializer:typeof(PrototypeIdListSerializer<ContentTileDefinition>))] [DataField("outputs", customTypeSerializer:typeof(PrototypeIdListSerializer<ContentTileDefinition>))]
private List<string>? _outputTiles; private List<string>? _outputTiles;
[DataField("placeTileSound")] SoundSpecifier _placeTileSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg");
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -46,8 +49,9 @@ namespace Content.Server.Tiles
private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0) private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0)
{ {
mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Robust.Shared.Map.Tile(tileId)); mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId));
SoundSystem.Play(Filter.Pvs(location), "/Audio/Items/genhit.ogg", location, AudioHelpers.WithVariation(0.125f)); if(_placeTileSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(location), sound, location, AudioHelpers.WithVariation(0.125f));
} }
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)

View File

@@ -13,6 +13,7 @@ using Content.Shared.Examine;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Notification; using Content.Shared.Notification;
using Content.Shared.Notification.Managers; using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Toilet; using Content.Shared.Toilet;
using Content.Shared.Tool; using Content.Shared.Tool;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -22,6 +23,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -42,6 +44,8 @@ namespace Content.Server.Toilet
[ViewVariables] private SecretStashComponent _secretStash = default!; [ViewVariables] private SecretStashComponent _secretStash = default!;
[DataField("toggleSound")] SoundSpecifier _toggleSound = new SoundPathSpecifier("/Audio/Effects/toilet_seat_down.ogg");
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -127,7 +131,8 @@ namespace Content.Server.Toilet
public void ToggleToiletSeat() public void ToggleToiletSeat()
{ {
IsSeatUp = !IsSeatUp; IsSeatUp = !IsSeatUp;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/toilet_seat_down.ogg", Owner, AudioHelpers.WithVariation(0.05f)); if(_toggleSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f));
UpdateSprite(); UpdateSprite();
} }

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.NetIDs; using Content.Shared.NetIDs;
using Content.Shared.Sound;
using Content.Shared.Tool; using Content.Shared.Tool;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -32,13 +33,10 @@ namespace Content.Server.Tools.Components
public string Sprite { get; } = string.Empty; public string Sprite { get; } = string.Empty;
[DataField("useSound")] [DataField("useSound")]
public string Sound { get; } = string.Empty; public SoundSpecifier Sound { get; } = default!;
[DataField("useSoundCollection")]
public string SoundCollection { get; } = string.Empty;
[DataField("changeSound")] [DataField("changeSound")]
public string ChangeSound { get; } = string.Empty; public SoundSpecifier ChangeSound { get; } = default!;
} }
public override string Name => "MultiTool"; public override string Name => "MultiTool";
@@ -62,8 +60,8 @@ namespace Content.Server.Tools.Components
_currentTool = (_currentTool + 1) % _tools.Count; _currentTool = (_currentTool + 1) % _tools.Count;
SetTool(); SetTool();
var current = _tools[_currentTool]; var current = _tools[_currentTool];
if(!string.IsNullOrEmpty(current.ChangeSound)) if(current.ChangeSound.TryGetSound(out var changeSound))
SoundSystem.Play(Filter.Pvs(Owner), current.ChangeSound, Owner); SoundSystem.Play(Filter.Pvs(Owner), changeSound, Owner);
} }
private void SetTool() private void SetTool()
@@ -73,7 +71,6 @@ namespace Content.Server.Tools.Components
var current = _tools[_currentTool]; var current = _tools[_currentTool];
_tool.UseSound = current.Sound; _tool.UseSound = current.Sound;
_tool.UseSoundCollection = current.SoundCollection;
_tool.Qualities = current.Behavior; _tool.Qualities = current.Behavior;
if (_sprite == null) return; if (_sprite == null) return;

View File

@@ -4,6 +4,7 @@ using Content.Server.DoAfter;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Tool; using Content.Shared.Tool;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -44,10 +45,7 @@ namespace Content.Server.Tools.Components
public float SpeedModifier { get; set; } = 1; public float SpeedModifier { get; set; } = 1;
[DataField("useSound")] [DataField("useSound")]
public string? UseSound { get; set; } public SoundSpecifier UseSound { get; set; } = default!;
[DataField("useSoundCollection")]
public string? UseSoundCollection { get; set; }
public void AddQuality(ToolQuality quality) public void AddQuality(ToolQuality quality)
{ {
@@ -96,30 +94,10 @@ namespace Content.Server.Tools.Components
return true; return true;
} }
protected void PlaySoundCollection(string? name, float volume = -5f) public void PlayUseSound(float volume = -5f)
{ {
if (string.IsNullOrEmpty(name)) if(UseSound.TryGetSound(out var useSound))
{ SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
return;
}
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
public void PlayUseSound(float volume=-5f)
{
if (string.IsNullOrEmpty(UseSoundCollection))
{
if (!string.IsNullOrEmpty(UseSound))
{
SoundSystem.Play(Filter.Pvs(Owner), UseSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume));
}
}
else
{
PlaySoundCollection(UseSoundCollection, volume);
}
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More