diff --git a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs index df9b94be07..264dfd64cb 100644 --- a/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs +++ b/Content.Client/Disposal/Visualizers/DisposalUnitVisualizer.cs @@ -59,10 +59,7 @@ namespace Content.Client.Disposal.Visualizers var sound = new AnimationTrackPlaySound(); _flushAnimation.AnimationTracks.Add(sound); - if (_flushSound.TryGetSound(out var flushSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(flushSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound.GetSound(), 0)); } private void ChangeState(AppearanceComponent appearance) diff --git a/Content.Client/Doors/AirlockVisualizer.cs b/Content.Client/Doors/AirlockVisualizer.cs index 4f5a745e01..ef05e75125 100644 --- a/Content.Client/Doors/AirlockVisualizer.cs +++ b/Content.Client/Doors/AirlockVisualizer.cs @@ -55,10 +55,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); CloseAnimation.AnimationTracks.Add(sound); - if (_closeSound.TryGetSound(out var closeSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(closeSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_closeSound.GetSound(), 0)); } OpenAnimation = new Animation {Length = TimeSpan.FromSeconds(_delay)}; @@ -81,10 +78,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); OpenAnimation.AnimationTracks.Add(sound); - if (_openSound.TryGetSound(out var openSound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(openSound, 0)); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_openSound.GetSound(), 0)); } DenyAnimation = new Animation {Length = TimeSpan.FromSeconds(0.3f)}; @@ -97,10 +91,7 @@ namespace Content.Client.Doors var sound = new AnimationTrackPlaySound(); DenyAnimation.AnimationTracks.Add(sound); - if (_denySound.TryGetSound(out var denySound)) - { - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(denySound, 0, () => AudioHelpers.WithVariation(0.05f))); - } + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_denySound.GetSound(), 0, () => AudioHelpers.WithVariation(0.05f))); } } diff --git a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs index 4d629dcd67..368e465c74 100644 --- a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs +++ b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs @@ -18,7 +18,7 @@ namespace Content.Client.Light.Visualizers { [DataField("minBlinkingTime")] private float _minBlinkingTime = 0.5f; [DataField("maxBlinkingTime")] private float _maxBlinkingTime = 2; - [DataField("blinkingSound")] private SoundSpecifier _blinkingSound = default!; + [DataField("blinkingSound", required: true)] private SoundSpecifier _blinkingSound = default!; private bool _wasBlinking; @@ -97,7 +97,7 @@ namespace Content.Client.Light.Visualizers var randomTime = random.NextFloat() * (_maxBlinkingTime - _minBlinkingTime) + _minBlinkingTime; - var blinkingAnim = new Animation() + var blinkingAnim = new Animation() { Length = TimeSpan.FromSeconds(randomTime), AnimationTracks = @@ -123,18 +123,15 @@ namespace Content.Client.Light.Visualizers } } } - }; + }; - if (_blinkingSound.TryGetSound(out var blinkingSound)) + blinkingAnim.AnimationTracks.Add(new AnimationTrackPlaySound() { - blinkingAnim.AnimationTracks.Add(new AnimationTrackPlaySound() + KeyFrames = { - KeyFrames = - { - new AnimationTrackPlaySound.KeyFrame(blinkingSound, 0.5f) - } - }); - } + new AnimationTrackPlaySound.KeyFrame(_blinkingSound.GetSound(), 0.5f) + } + }); return blinkingAnim; } diff --git a/Content.Client/PDA/PDAComponent.cs b/Content.Client/PDA/PDAComponent.cs index 7538b70906..353e9675a5 100644 --- a/Content.Client/PDA/PDAComponent.cs +++ b/Content.Client/PDA/PDAComponent.cs @@ -24,16 +24,14 @@ namespace Content.Client.PDA public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null) { base.HandleNetworkMessage(message, netChannel, session); - switch(message) + switch (message) { case PDAUplinkBuySuccessMessage: - if(BuySuccessSound.TryGetSound(out var buySuccessSound)) - SoundSystem.Play(Filter.Local(), buySuccessSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Local(), BuySuccessSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; case PDAUplinkInsufficientFundsMessage: - if(InsufficientFundsSound.TryGetSound(out var insufficientFundsSound)) - SoundSystem.Play(Filter.Local(), insufficientFundsSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), InsufficientFundsSound.GetSound(), Owner, AudioParams.Default); break; } } diff --git a/Content.Client/Trigger/TimerTriggerVisualizer.cs b/Content.Client/Trigger/TimerTriggerVisualizer.cs index 246a4c181a..c712c88c3c 100644 --- a/Content.Client/Trigger/TimerTriggerVisualizer.cs +++ b/Content.Client/Trigger/TimerTriggerVisualizer.cs @@ -15,7 +15,7 @@ namespace Content.Client.Trigger { private const string AnimationKey = "priming_animation"; - [DataField("countdown_sound", required: true)] + [DataField("countdown_sound")] private SoundSpecifier _countdownSound = default!; private Animation PrimingAnimation = default!; @@ -29,12 +29,9 @@ namespace Content.Client.Trigger flick.LayerKey = TriggerVisualLayers.Base; flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("primed", 0f)); - if (_countdownSound.TryGetSound(out var countdownSound)) - { - var sound = new AnimationTrackPlaySound(); - PrimingAnimation.AnimationTracks.Add(sound); - sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(countdownSound, 0)); - } + var sound = new AnimationTrackPlaySound(); + PrimingAnimation.AnimationTracks.Add(sound); + sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_countdownSound.GetSound(), 0)); } } diff --git a/Content.Server/AME/Components/AMEControllerComponent.cs b/Content.Server/AME/Components/AMEControllerComponent.cs index 785431be0e..f25c93b023 100644 --- a/Content.Server/AME/Components/AMEControllerComponent.cs +++ b/Content.Server/AME/Components/AMEControllerComponent.cs @@ -75,7 +75,7 @@ namespace Content.Server.AME.Components internal void OnUpdate(float frameTime) { - if(!_injecting) + if (!_injecting) { return; } @@ -88,11 +88,11 @@ namespace Content.Server.AME.Components } var jar = _jarSlot.ContainedEntity; - if(jar is null) + if (jar is null) return; jar.TryGetComponent(out var fuelJar); - if(fuelJar != null && _powerSupplier != null) + if (fuelJar != null && _powerSupplier != null) { var availableInject = fuelJar.FuelAmount >= InjectionAmount ? InjectionAmount : fuelJar.FuelAmount; _powerSupplier.MaxSupply = group.InjectFuel(availableInject, out var overloading); @@ -105,7 +105,7 @@ namespace Content.Server.AME.Components UpdateDisplay(_stability); - if(_stability <= 0) { group.ExplodeCores(); } + if (_stability <= 0) { group.ExplodeCores(); } } @@ -229,7 +229,7 @@ namespace Content.Server.AME.Components return; var jar = _jarSlot.ContainedEntity; - if(jar is null) + if (jar is null) return; _jarSlot.Remove(jar); @@ -262,7 +262,7 @@ namespace Content.Server.AME.Components private void UpdateDisplay(int stability) { - if(_appearance == null) { return; } + if (_appearance == null) { return; } _appearance.TryGetData(AMEControllerVisuals.DisplayState, out var state); @@ -291,7 +291,7 @@ namespace Content.Server.AME.Components private bool IsMasterController() { - if(GetAMENodeGroup()?.MasterController == this) + if (GetAMENodeGroup()?.MasterController == this) { return true; } @@ -315,14 +315,12 @@ namespace Content.Server.AME.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } private void InjectSound(bool overloading) { - if(_injectSound.TryGetSound(out var injectSound)) - SoundSystem.Play(Filter.Pvs(Owner), injectSound, Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); + SoundSystem.Play(Filter.Pvs(Owner), _injectSound.GetSound(), Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); } async Task IInteractUsing.InteractUsing(InteractUsingEventArgs args) diff --git a/Content.Server/AME/Components/AMEPartComponent.cs b/Content.Server/AME/Components/AMEPartComponent.cs index 8dacbf8763..d7971c0f00 100644 --- a/Content.Server/AME/Components/AMEPartComponent.cs +++ b/Content.Server/AME/Components/AMEPartComponent.cs @@ -51,8 +51,7 @@ namespace Content.Server.AME.Components var ent = _serverEntityManager.SpawnEntity("AMEShielding", mapGrid.GridTileToLocal(snapPos)); ent.Transform.LocalRotation = Owner.Transform.LocalRotation; - if(_unwrapSound.TryGetSound(out var unwrapSound)) - SoundSystem.Play(Filter.Pvs(Owner), unwrapSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _unwrapSound.GetSound(), Owner); Owner.Delete(); diff --git a/Content.Server/Actions/Actions/DisarmAction.cs b/Content.Server/Actions/Actions/DisarmAction.cs index 2af0fe9a88..a9d1074f22 100644 --- a/Content.Server/Actions/Actions/DisarmAction.cs +++ b/Content.Server/Actions/Actions/DisarmAction.cs @@ -78,8 +78,7 @@ namespace Content.Server.Actions.Actions if (random.Prob(_failProb)) { - if(PunchMissSound.TryGetSound(out var punchMissSound)) - SoundSystem.Play(Filter.Pvs(args.Performer), punchMissSound, args.Performer, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(args.Performer), PunchMissSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f)); args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients", ("performerName", args.Performer.Name), @@ -90,9 +89,9 @@ namespace Content.Server.Actions.Actions return; } - system.SendAnimation("disarm", angle, args.Performer, args.Performer, new []{ args.Target }); + system.SendAnimation("disarm", angle, args.Performer, args.Performer, new[] { args.Target }); - var eventArgs = new DisarmedActEventArgs() {Target = args.Target, Source = args.Performer, PushProbability = _pushProb}; + var eventArgs = new DisarmedActEventArgs() { Target = args.Target, Source = args.Performer, PushProbability = _pushProb }; // Sort by priority. Array.Sort(disarmedActs, (a, b) => a.Priority.CompareTo(b.Priority)); @@ -103,8 +102,7 @@ namespace Content.Server.Actions.Actions return; } - if(DisarmSuccessSound.TryGetSound(out var disarmSuccessSound)) - SoundSystem.Play(Filter.Pvs(args.Performer), disarmSuccessSound, args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(args.Performer), DisarmSuccessSound.GetSound(), args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); } } } diff --git a/Content.Server/Actions/Actions/ScreamAction.cs b/Content.Server/Actions/Actions/ScreamAction.cs index a98c5d3599..c07f3b5858 100644 --- a/Content.Server/Actions/Actions/ScreamAction.cs +++ b/Content.Server/Actions/Actions/ScreamAction.cs @@ -26,9 +26,9 @@ namespace Content.Server.Actions.Actions [Dependency] private readonly IRobustRandom _random = default!; - [DataField("male")] private SoundSpecifier _male = default!; - [DataField("female")] private SoundSpecifier _female = default!; - [DataField("wilhelm")] private SoundSpecifier _wilhelm = default!; + [DataField("male", required: true)] private SoundSpecifier _male = default!; + [DataField("female", required: true)] private SoundSpecifier _female = default!; + [DataField("wilhelm", required: true)] private SoundSpecifier _wilhelm = default!; /// seconds [DataField("cooldown")] private float _cooldown = 10; @@ -44,21 +44,19 @@ namespace Content.Server.Actions.Actions if (!args.Performer.TryGetComponent(out var humanoid)) return; if (!args.Performer.TryGetComponent(out var actions)) return; - if (_random.Prob(.01f) && _wilhelm.TryGetSound(out var wilhelm)) + if (_random.Prob(.01f)) { - SoundSystem.Play(Filter.Pvs(args.Performer), wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm.GetSound(), args.Performer, AudioParams.Default.WithVolume(Volume)); } else { switch (humanoid.Sex) { case Sex.Male: - if (_male.TryGetSound(out var male)) - SoundSystem.Play(Filter.Pvs(args.Performer), male, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _male.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; case Sex.Female: - if (_female.TryGetSound(out var female)) - SoundSystem.Play(Filter.Pvs(args.Performer), female, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); + SoundSystem.Play(Filter.Pvs(args.Performer), _female.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Actions/Spells/GiveItemSpell.cs b/Content.Server/Actions/Spells/GiveItemSpell.cs index 01d4826fde..f5151c4ae0 100644 --- a/Content.Server/Actions/Spells/GiveItemSpell.cs +++ b/Content.Server/Actions/Spells/GiveItemSpell.cs @@ -28,7 +28,7 @@ namespace Content.Server.Actions.Spells [ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f; [ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!; - [ViewVariables] [DataField("castSound")] public SoundSpecifier CastSound { get; set; } = default!; + [ViewVariables] [DataField("castSound", required: true)] 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 //Not sure if needs fixing @@ -69,8 +69,7 @@ namespace Content.Server.Actions.Spells handsComponent.PutInHandOrDrop(itemComponent); - if (CastSound.TryGetSound(out var castSound)) - SoundSystem.Play(Filter.Pvs(caster), castSound, caster); + SoundSystem.Play(Filter.Pvs(caster), CastSound.GetSound(), caster); } } } diff --git a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs index 01e97629cc..a9018095fb 100644 --- a/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs +++ b/Content.Server/Arcade/Components/SpaceVillainArcadeComponent.cs @@ -45,18 +45,26 @@ namespace Content.Server.Arcade.Components [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 _possibleFightVerbs = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleFightVerbs")] + private List _possibleFightVerbs = new List() {"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"}; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List _possibleFirstEnemyNames = new List(){ + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleFirstEnemyNames")] + private List _possibleFirstEnemyNames = new List(){ "the Automatic", "Farmer", "Lord", "Professor", "the Cuban", "the Evil", "the Dread King", "the Space", "Lord", "the Great", "Duke", "General" }; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleLastEnemyNames")] private List _possibleLastEnemyNames = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleLastEnemyNames")] + private List _possibleLastEnemyNames = new List() { "Melonoid", "Murdertron", "Sorcerer", "Ruin", "Jeff", "Ectoplasm", "Crushulon", "Uhangoid", "Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn" }; - [ViewVariables(VVAccess.ReadWrite)] [DataField("possibleRewards")] private List _possibleRewards = new List() + [ViewVariables(VVAccess.ReadWrite)] + [DataField("possibleRewards")] + private List _possibleRewards = new List() { "ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan", "ToyMarauder", "ToyMauler", "ToyGygax", "ToyOdysseus", "ToyOwlman", "ToyDeathRipley", @@ -65,10 +73,10 @@ namespace Content.Server.Arcade.Components void IActivate.Activate(ActivateEventArgs eventArgs) { - if(!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) + if (!Powered || !eventArgs.User.TryGetComponent(out ActorComponent? actor)) return; - if(!EntitySystem.Get().CanInteract(eventArgs.User)) + if (!EntitySystem.Get().CanInteract(eventArgs.User)) return; _game ??= new SpaceVillainGame(this); @@ -76,7 +84,8 @@ namespace Content.Server.Arcade.Components if (_wiresComponent?.IsPanelOpen == true) { _wiresComponent.OpenInterface(actor.PlayerSession); - } else + } + else { UserInterface?.Toggle(actor.PlayerSession); } @@ -105,7 +114,7 @@ namespace Content.Server.Arcade.Components private void OnOnPowerStateChanged(PowerChangedMessage e) { - if(e.Powered) return; + if (e.Powered) return; UserInterface?.CloseAll(); } @@ -130,8 +139,7 @@ namespace Content.Server.Arcade.Components _game?.ExecutePlayerAction(msg.PlayerAction); break; case PlayerAction.NewGame: - if(_newGameSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(Owner), _newGameSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4f)); _game = new SpaceVillainGame(this); UserInterface?.SendMessage(_game.GenerateMetaDataMessage()); @@ -260,7 +268,7 @@ namespace Content.Server.Arcade.Components private string _latestPlayerActionMessage = ""; private string _latestEnemyActionMessage = ""; - public SpaceVillainGame(SpaceVillainArcadeComponent owner) : this(owner, owner.GenerateFightVerb(), owner.GenerateEnemyName()){} + public SpaceVillainGame(SpaceVillainArcadeComponent owner) : this(owner, owner.GenerateFightVerb(), owner.GenerateEnemyName()) { } public SpaceVillainGame(SpaceVillainArcadeComponent owner, string fightVerb, string enemyName) { @@ -277,7 +285,7 @@ namespace Content.Server.Arcade.Components /// private void ValidateVars() { - if(_owner._overflowFlag) return; + if (_owner._overflowFlag) return; if (_playerHp > _playerHpMax) _playerHp = _playerHpMax; if (_playerMp > _playerMpMax) _playerMp = _playerMpMax; @@ -300,9 +308,8 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message", ("enemyName", _enemyName), ("attackAmount", attackAmount)); - if(_owner._playerAttackSound.TryGetSound(out var playerAttackSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerAttackSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._enemyInvincibilityFlag) + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerAttackSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if (!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -312,18 +319,16 @@ namespace Content.Server.Arcade.Components _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message", ("magicPointAmount", pointAmount), ("healAmount", healAmount)); - if(_owner._playerHealSound.TryGetSound(out var playerHealSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerHealSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); - if(!_owner._playerInvincibilityFlag) + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerHealSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); + if (!_owner._playerInvincibilityFlag) _playerMp -= pointAmount; _playerHp += healAmount; _turtleTracker++; break; case PlayerAction.Recharge: var chargeAmount = _random.Next(4, 7); - _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message",("regainedPoints", chargeAmount)); - if(_owner._playerChargeSound.TryGetSound(out var playerChargeSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), playerChargeSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + _latestPlayerActionMessage = Loc.GetString("space-villain-game-player-recharge-message", ("regainedPoints", chargeAmount)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._playerChargeSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); _playerMp += chargeAmount; _turtleTracker -= _turtleTracker > 0 ? 1 : 0; break; @@ -355,10 +360,9 @@ namespace Content.Server.Arcade.Components { _running = false; 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); - if(_owner._winSound.TryGetSound(out var winSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), winSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._winSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); _owner.ProcessWin(); return false; } @@ -369,10 +373,9 @@ namespace Content.Server.Arcade.Components { _running = false; 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); - if(_owner._gameOverSound.TryGetSound(out var gameOverSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._gameOverSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } if (_enemyHp <= 0 || _enemyMp <= 0) @@ -381,8 +384,7 @@ namespace Content.Server.Arcade.Components UpdateUi(Loc.GetString("space-villain-game-player-loses-message"), Loc.GetString("space-villain-game-enemy-dies-with-player-message ", ("enemyName", _enemyName)), true); - if (_owner._gameOverSound.TryGetSound(out var gameOverSound)) - SoundSystem.Play(Filter.Pvs(_owner.Owner), gameOverSound, _owner.Owner, AudioParams.Default.WithVolume(-4f)); + SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._gameOverSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f)); return false; } @@ -419,7 +421,8 @@ namespace Content.Server.Arcade.Components if (_owner._playerInvincibilityFlag) return; _playerHp -= boomAmount; _turtleTracker--; - }else if (_enemyMp <= 5 && _random.Prob(0.7f)) + } + else if (_enemyMp <= 5 && _random.Prob(0.7f)) { var stealAmount = _random.Next(2, 3); _latestEnemyActionMessage = Loc.GetString("space-villain-game-enemy-steals-player-power-message", @@ -428,7 +431,8 @@ namespace Content.Server.Arcade.Components if (_owner._playerInvincibilityFlag) return; _playerMp -= stealAmount; _enemyMp += stealAmount; - }else if (_enemyHp <= 10 && _enemyMp > 4) + } + else if (_enemyHp <= 10 && _enemyMp > 4) { _enemyHp += 4; _enemyMp -= 4; diff --git a/Content.Server/Atmos/Components/GasTankComponent.cs b/Content.Server/Atmos/Components/GasTankComponent.cs index cf341e3c01..bd1f2ac7b9 100644 --- a/Content.Server/Atmos/Components/GasTankComponent.cs +++ b/Content.Server/Atmos/Components/GasTankComponent.cs @@ -284,8 +284,7 @@ namespace Content.Server.Atmos.Components if(environment != null) atmosphereSystem.Merge(environment, Air); - if(_ruptureSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f)); Owner.QueueDelete(); return; diff --git a/Content.Server/Body/BodyComponent.cs b/Content.Server/Body/BodyComponent.cs index 87d14a05c3..d1940ff73a 100644 --- a/Content.Server/Body/BodyComponent.cs +++ b/Content.Server/Body/BodyComponent.cs @@ -104,8 +104,7 @@ namespace Content.Server.Body { base.Gib(gibParts); - if(_gibSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(Owner), _gibSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.025f)); if (Owner.TryGetComponent(out ContainerManagerComponent? container)) { diff --git a/Content.Server/Botany/Components/PlantHolderComponent.cs b/Content.Server/Botany/Components/PlantHolderComponent.cs index 3ee1a289ad..9b43f34f59 100644 --- a/Content.Server/Botany/Components/PlantHolderComponent.cs +++ b/Content.Server/Botany/Components/PlantHolderComponent.cs @@ -723,10 +723,7 @@ namespace Content.Server.Botany.Components sprayed = true; amount = ReagentUnit.New(1); - if (spray.SpraySound.TryGetSound(out var spraySound)) - { - SoundSystem.Play(Filter.Pvs(usingItem), spraySound, usingItem, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem, AudioHelpers.WithVariation(0.125f)); } var split = solution.Drain(amount); diff --git a/Content.Server/Buckle/Components/BuckleComponent.cs b/Content.Server/Buckle/Components/BuckleComponent.cs index a3c4c705c0..2232045831 100644 --- a/Content.Server/Buckle/Components/BuckleComponent.cs +++ b/Content.Server/Buckle/Components/BuckleComponent.cs @@ -50,7 +50,7 @@ namespace Content.Server.Buckle.Components /// [DataField("delay")] [ViewVariables] - private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f); + private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f); /// /// The time that this entity buckled at. @@ -199,7 +199,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-already-buckled-message" - : "buckle-component-other-already-buckled-message",("owner", Owner)); + : "buckle-component-other-already-buckled-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -212,7 +212,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-buckle-message" - : "buckle-component-other-cannot-buckle-message",("owner", Owner)); + : "buckle-component-other-cannot-buckle-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -225,7 +225,7 @@ namespace Content.Server.Buckle.Components { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-fit-message" - : "buckle-component-other-cannot-fit-message",("owner", Owner)); + : "buckle-component-other-cannot-fit-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; @@ -241,16 +241,13 @@ namespace Content.Server.Buckle.Components return false; } - if(strap.BuckleSound.TryGetSound(out var buckleSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), buckleSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), strap.BuckleSound.GetSound(), Owner); if (!strap.TryAdd(this)) { var message = Loc.GetString(Owner == user ? "buckle-component-cannot-buckle-message" - : "buckle-component-other-cannot-buckle-message",("owner", Owner)); + : "buckle-component-other-cannot-buckle-message", ("owner", Owner)); Owner.PopupMessage(user, message); return false; } @@ -352,11 +349,8 @@ namespace Content.Server.Buckle.Components UpdateBuckleStatus(); oldBuckledTo.Remove(this); - if (oldBuckledTo.UnbuckleSound.TryGetSound(out var unbuckleSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), unbuckleSound, Owner); - } - + SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound.GetSound(), Owner); + SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner)); return true; diff --git a/Content.Server/Cabinet/ItemCabinetComponent.cs b/Content.Server/Cabinet/ItemCabinetComponent.cs index dd72e2d3d5..89eb94363b 100644 --- a/Content.Server/Cabinet/ItemCabinetComponent.cs +++ b/Content.Server/Cabinet/ItemCabinetComponent.cs @@ -24,7 +24,7 @@ namespace Content.Server.Cabinet /// Sound to be played when the cabinet door is opened. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("doorSound")] + [DataField("doorSound", required: true)] public SoundSpecifier DoorSound { get; set; } = default!; /// diff --git a/Content.Server/Cabinet/ItemCabinetSystem.cs b/Content.Server/Cabinet/ItemCabinetSystem.cs index 39772ee9b6..b56e1d52cd 100644 --- a/Content.Server/Cabinet/ItemCabinetSystem.cs +++ b/Content.Server/Cabinet/ItemCabinetSystem.cs @@ -36,7 +36,7 @@ namespace Content.Server.Cabinet comp.ItemContainer = owner.EnsureContainer("item_cabinet", out _); - if(comp.SpawnPrototype != null) + if (comp.SpawnPrototype != null) comp.ItemContainer.Insert(EntityManager.SpawnEntity(comp.SpawnPrototype, owner.Transform.Coordinates)); UpdateVisuals(comp); @@ -146,10 +146,7 @@ namespace Content.Server.Cabinet private static void ClickLatchSound(ItemCabinetComponent comp) { - if(comp.DoorSound.TryGetSound(out var doorSound)) - { - SoundSystem.Play(Filter.Pvs(comp.Owner), doorSound, comp.Owner, AudioHelpers.WithVariation(0.15f)); - } + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound.GetSound(), comp.Owner, AudioHelpers.WithVariation(0.15f)); } } diff --git a/Content.Server/Cargo/Components/CargoConsoleComponent.cs b/Content.Server/Cargo/Components/CargoConsoleComponent.cs index 77b31ab890..35c51caa80 100644 --- a/Content.Server/Cargo/Components/CargoConsoleComponent.cs +++ b/Content.Server/Cargo/Components/CargoConsoleComponent.cs @@ -115,10 +115,9 @@ namespace Content.Server.Cargo.Components } if (!_cargoConsoleSystem.AddOrder(orders.Database.Id, msg.Requester, msg.Reason, msg.ProductId, - msg.Amount, _bankAccount.Id) && - _errorSound.TryGetSound(out var errorSound)) + msg.Amount, _bankAccount.Id)) { - SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), _errorSound.GetSound(), Owner, AudioParams.Default); } break; } @@ -146,11 +145,9 @@ namespace Content.Server.Cargo.Components || !_cargoConsoleSystem.CheckBalance(_bankAccount.Id, (-product.PointCost) * order.Amount) || !_cargoConsoleSystem.ApproveOrder(orders.Database.Id, msg.OrderNumber) || !_cargoConsoleSystem.ChangeBalance(_bankAccount.Id, (-product.PointCost) * order.Amount)) - && - _errorSound.TryGetSound(out var errorSound) ) { - SoundSystem.Play(Filter.Local(), errorSound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Local(), _errorSound.GetSound(), Owner, AudioParams.Default); break; } UpdateUIState(); diff --git a/Content.Server/Cargo/Components/CargoTelepadComponent.cs b/Content.Server/Cargo/Components/CargoTelepadComponent.cs index d26d0834e6..30becc9650 100644 --- a/Content.Server/Cargo/Components/CargoTelepadComponent.cs +++ b/Content.Server/Cargo/Components/CargoTelepadComponent.cs @@ -74,8 +74,7 @@ namespace Content.Server.Cargo.Components { if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0) { - if (_teleportSound.TryGetSound(out var teleportSound)) - SoundSystem.Play(Filter.Pvs(Owner), teleportSound, Owner, AudioParams.Default.WithVolume(-8f)); + SoundSystem.Play(Filter.Pvs(Owner), _teleportSound.GetSound(), Owner, AudioParams.Default.WithVolume(-8f)); Owner.EntityManager.SpawnEntity(_teleportQueue[0].Product, Owner.Transform.Coordinates); _teleportQueue.RemoveAt(0); if (Owner.TryGetComponent(out var spriteComponent) && spriteComponent.LayerCount > 0) diff --git a/Content.Server/Chemistry/Components/ChemMasterComponent.cs b/Content.Server/Chemistry/Components/ChemMasterComponent.cs index 9f4ca18bc5..55d8a45600 100644 --- a/Content.Server/Chemistry/Components/ChemMasterComponent.cs +++ b/Content.Server/Chemistry/Components/ChemMasterComponent.cs @@ -420,8 +420,7 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/Components/HyposprayComponent.cs b/Content.Server/Chemistry/Components/HyposprayComponent.cs index fd3974fac6..63f3520283 100644 --- a/Content.Server/Chemistry/Components/HyposprayComponent.cs +++ b/Content.Server/Chemistry/Components/HyposprayComponent.cs @@ -72,8 +72,7 @@ namespace Content.Server.Chemistry.Components meleeSys.SendLunge(angle, user); } - if(_injectSound.TryGetSound(out var injectSound)) - SoundSystem.Play(Filter.Pvs(user), injectSound, user); + SoundSystem.Play(Filter.Pvs(user), _injectSound.GetSound(), user); var targetSolution = target.GetComponent(); diff --git a/Content.Server/Chemistry/Components/PillComponent.cs b/Content.Server/Chemistry/Components/PillComponent.cs index 5454744f0b..f3be401e3b 100644 --- a/Content.Server/Chemistry/Components/PillComponent.cs +++ b/Content.Server/Chemistry/Components/PillComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components public override string Name => "Pill"; [ViewVariables] - [DataField("useSound")] + [DataField("useSound", required: true)] protected override SoundSpecifier UseSound { get; set; } = default!; [ViewVariables] @@ -99,10 +99,7 @@ namespace Content.Server.Chemistry.Components firstStomach.TryTransferSolution(split); - if (UseSound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(trueTarget), sound, trueTarget, AudioParams.Default.WithVolume(-1f)); - } + SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message")); diff --git a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs index 74b316f315..03e239e5c9 100644 --- a/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs +++ b/Content.Server/Chemistry/Components/ReagentDispenserComponent.cs @@ -47,7 +47,8 @@ namespace Content.Server.Chemistry.Components [ViewVariables] private ContainerSlot _beakerContainer = default!; [ViewVariables] [DataField("pack")] private string _packPrototypeId = ""; - [DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("clickSound")] + private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); [ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null; [ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10); @@ -361,8 +362,7 @@ namespace Content.Server.Chemistry.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } [Verb] diff --git a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs index d9dfd5d502..cecc997ecf 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemicalReactionSystem.cs @@ -12,8 +12,7 @@ namespace Content.Server.Chemistry.EntitySystems { base.OnReaction(reaction, owner, unitReactions); - if (reaction.Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(owner), sound, owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), reaction.Sound.GetSound(), owner.Transform.Coordinates); } } } diff --git a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs index 2b08dabbda..cf3ab9882c 100644 --- a/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs +++ b/Content.Server/Chemistry/ReactionEffects/AreaReactionEffect.cs @@ -80,7 +80,7 @@ namespace Content.Server.Chemistry.ReactionEffects /// /// Sound that will get played when this reaction effect occurs. /// - [DataField("sound")] private SoundSpecifier _sound = default!; + [DataField("sound", required: true)] private SoundSpecifier _sound = default!; protected AreaReactionEffect() { @@ -136,10 +136,7 @@ namespace Content.Server.Chemistry.ReactionEffects areaEffectComponent.TryAddSolution(solution); areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay); - if (_sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(solutionEntity), sound, solutionEntity, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(solutionEntity), _sound.GetSound(), solutionEntity, AudioHelpers.WithVariation(0.125f)); } protected abstract SolutionAreaEffectComponent? GetAreaEffectComponent(IEntity entity); diff --git a/Content.Server/Construction/Completions/PlaySound.cs b/Content.Server/Construction/Completions/PlaySound.cs index a336d70827..3fbf6f5a1b 100644 --- a/Content.Server/Construction/Completions/PlaySound.cs +++ b/Content.Server/Construction/Completions/PlaySound.cs @@ -14,12 +14,11 @@ namespace Content.Server.Construction.Completions [DataDefinition] public class PlaySound : IGraphAction { - [DataField("sound")] public SoundSpecifier Sound { get; private set; } = default!; + [DataField("sound", required: true)] public SoundSpecifier Sound { get; private set; } = default!; public async Task PerformAction(IEntity entity, IEntity? user) { - if(Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(entity), Sound.GetSound(), entity, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Crayon/CrayonComponent.cs b/Content.Server/Crayon/CrayonComponent.cs index d942a08a21..97df4f961a 100644 --- a/Content.Server/Crayon/CrayonComponent.cs +++ b/Content.Server/Crayon/CrayonComponent.cs @@ -30,7 +30,7 @@ namespace Content.Server.Crayon [Dependency] private readonly IPrototypeManager _prototypeManager = default!; //TODO: useSound - [DataField("useSound")] + [DataField("useSound", required: true)] private SoundSpecifier _useSound = default!; [ViewVariables] @@ -139,10 +139,7 @@ namespace Content.Server.Crayon appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation); } - if (_useSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(Owner), _useSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); // Decrease "Ammo" Charges--; diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index 2bdb62c3e8..fd550d228d 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -231,13 +231,11 @@ namespace Content.Server.Cuffs.Components if (isOwner) { - if (cuff.StartBreakoutSound.TryGetSound(out var startBreakoutSound)) - SoundSystem.Play(Filter.Pvs(Owner), startBreakoutSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound.GetSound(), Owner); } else { - if (cuff.StartUncuffSound.TryGetSound(out var startUncuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), startUncuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.StartUncuffSound.GetSound(), Owner); } var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; @@ -258,8 +256,7 @@ namespace Content.Server.Cuffs.Components if (result != DoAfterStatus.Cancelled) { - if (cuff.EndUncuffSound.TryGetSound(out var endUncuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), endUncuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound.GetSound(), Owner); Container.ForceRemove(cuffsToRemove); cuffsToRemove.Transform.AttachToGridOrMap(); @@ -289,7 +286,7 @@ namespace Content.Server.Cuffs.Components if (!isOwner) { - user.PopupMessage(Owner, Loc.GetString("cuffable-component-remove-cuffs-by-other-success-message",("otherName", user))); + user.PopupMessage(Owner, Loc.GetString("cuffable-component-remove-cuffs-by-other-success-message", ("otherName", user))); } } else @@ -305,7 +302,7 @@ namespace Content.Server.Cuffs.Components } else { - user.PopupMessage(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message",("cuffedHandCount", CuffedHandCount))); + user.PopupMessage(Loc.GetString("cuffable-component-remove-cuffs-partial-success-message", ("cuffedHandCount", CuffedHandCount))); } } } diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index 036c289af4..c652e00e2e 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -184,8 +184,7 @@ namespace Content.Server.Cuffs.Components 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))); - if (StartCuffSound.TryGetSound(out var startCuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), startCuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound.GetSound(), Owner); TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed); return true; @@ -222,8 +221,7 @@ namespace Content.Server.Cuffs.Components { if (cuffs.TryAddNewCuffs(user, Owner)) { - if (EndCuffSound.TryGetSound(out var endCuffSound)) - SoundSystem.Play(Filter.Pvs(Owner), endCuffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), EndCuffSound.GetSound(), Owner); 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))); diff --git a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs index aca43b5425..6632f13c97 100644 --- a/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs +++ b/Content.Server/Damage/Components/DamageOnHighSpeedImpactComponent.cs @@ -22,7 +22,7 @@ namespace Content.Server.Damage.Components public int BaseDamage { get; set; } = 5; [DataField("factor")] public float Factor { get; set; } = 1f; - [DataField("soundHit")] + [DataField("soundHit", required: true)] public SoundSpecifier SoundHit { get; set; } = default!; [DataField("stunChance")] public float StunChance { get; set; } = 0.25f; diff --git a/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs b/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs index db2ea230aa..9b11b23dd1 100644 --- a/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs +++ b/Content.Server/Damage/DamageOnHighSpeedImpactSystem.cs @@ -34,8 +34,7 @@ namespace Content.Server.Damage if (speed < component.MinimumSpeed) return; - if (component.SoundHit.TryGetSound(out var soundHit)) - SoundSystem.Play(Filter.Pvs(otherBody), soundHit, otherBody, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); + SoundSystem.Play(Filter.Pvs(otherBody), component.SoundHit.GetSound(), otherBody, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); if ((_gameTiming.CurTime - component.LastHit).TotalSeconds < component.DamageCooldown) return; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs index 67fad570ed..7847fb8f37 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/PlaySoundBehavior.cs @@ -15,15 +15,12 @@ namespace Content.Server.Destructible.Thresholds.Behaviors /// /// Sound played upon destruction. /// - [DataField("sound")] public SoundSpecifier Sound { get; set; } = default!; + [DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!; public void Execute(IEntity owner, DestructibleSystem system) { - if (Sound.TryGetSound(out var sound)) - { - 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.GetSound(), pos, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Dice/DiceComponent.cs b/Content.Server/Dice/DiceComponent.cs index 09abb9ade4..99bdf36eaa 100644 --- a/Content.Server/Dice/DiceComponent.cs +++ b/Content.Server/Dice/DiceComponent.cs @@ -64,8 +64,7 @@ namespace Content.Server.Dice public void PlayDiceEffect() { - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioParams.Default); } void IActivate.Activate(ActivateEventArgs eventArgs) diff --git a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs index c0e0eb8be1..fac13e2b7c 100644 --- a/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs +++ b/Content.Server/Disposal/Mailing/DisposalMailingUnitComponent.cs @@ -435,8 +435,7 @@ namespace Content.Server.Disposal.Mailing break; case UiButton.Power: TogglePower(); - if(_receivedMessageSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _receivedMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index a8cca2dbf4..5c1256202d 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -127,7 +127,7 @@ namespace Content.Server.Disposal.Tube.Components /// Returns a private DisposalRouterUserInterfaceState GetUserInterfaceState() { - if(_tags.Count <= 0) + if (_tags.Count <= 0) { return new DisposalRouterUserInterfaceState(""); } @@ -153,8 +153,7 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs index d5bb6e2098..03a4bd73b2 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTaggerComponent.cs @@ -119,8 +119,7 @@ namespace Content.Server.Disposal.Tube.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } /// diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index 00a92f09f8..1483a7b906 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -266,8 +266,7 @@ namespace Content.Server.Disposal.Tube.Components } _lastClang = _gameTiming.CurTime; - if(_clangSound.TryGetSound(out var clangSound)) - SoundSystem.Play(Filter.Pvs(Owner), clangSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _clangSound.GetSound(), Owner.Transform.Coordinates); break; } } diff --git a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs index 14c3c502f3..4b6987611a 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalUnitComponent.cs @@ -373,8 +373,7 @@ namespace Content.Server.Disposal.Unit.Components break; case UiButton.Power: TogglePower(); - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); break; default: throw new ArgumentOutOfRangeException(); diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs index 93fd5fba36..eee426e02e 100644 --- a/Content.Server/Doors/Components/AirlockComponent.cs +++ b/Content.Server/Doors/Components/AirlockComponent.cs @@ -359,7 +359,7 @@ namespace Content.Server.Doors.Components public void WiresUpdate(WiresUpdateEventArgs args) { - if(_doorComponent == null) + if (_doorComponent == null) { return; } @@ -463,13 +463,11 @@ namespace Content.Server.Doors.Components if (newBolts) { - if (_setBoltsDownSound.TryGetSound(out var boltsDownSound)) - SoundSystem.Play(Filter.Broadcast(), boltsDownSound, Owner); + SoundSystem.Play(Filter.Broadcast(), _setBoltsDownSound.GetSound(), Owner); } else { - if (_setBoltsUpSound.TryGetSound(out var boltsUpSound)) - SoundSystem.Play(Filter.Broadcast(), boltsUpSound, Owner); + SoundSystem.Play(Filter.Broadcast(), _setBoltsUpSound.GetSound(), Owner); } } } diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index dfa0e8e448..23ee6c3778 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -222,10 +222,9 @@ namespace Content.Server.Doors.Components { Open(); - if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0 - && _tryOpenDoorSound.TryGetSound(out var tryOpenDoorSound)) + if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0) { - SoundSystem.Play(Filter.Pvs(Owner), tryOpenDoorSound, Owner, AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), _tryOpenDoorSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2)); } } else diff --git a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs index d1acbe4087..83ea9bca05 100644 --- a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs +++ b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs @@ -14,7 +14,7 @@ namespace Content.Server.Explosion.Components public override string Name => "SoundOnTrigger"; [ViewVariables(VVAccess.ReadWrite)] - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier? Sound { get; set; } = null; } } diff --git a/Content.Server/Explosion/ExplosionHelper.cs b/Content.Server/Explosion/ExplosionHelper.cs index 234415799f..c2b1aa7e32 100644 --- a/Content.Server/Explosion/ExplosionHelper.cs +++ b/Content.Server/Explosion/ExplosionHelper.cs @@ -314,8 +314,7 @@ namespace Content.Server.Explosion var boundingBox = new Box2(epicenterMapPos - new Vector2(maxRange, maxRange), epicenterMapPos + new Vector2(maxRange, maxRange)); - if(_explosionSound.TryGetSound(out var explosionSound)) - SoundSystem.Play(Filter.Broadcast(), explosionSound, epicenter); + SoundSystem.Play(Filter.Broadcast(), _explosionSound.GetSound(), epicenter); DamageEntitiesInRange(epicenter, boundingBox, devastationRange, heavyImpactRange, maxRange, mapId); var mapGridsNear = mapManager.FindGridsIntersecting(mapId, boundingBox); diff --git a/Content.Server/Extinguisher/FireExtinguisherComponent.cs b/Content.Server/Extinguisher/FireExtinguisherComponent.cs index 8b87152686..6492ff6803 100644 --- a/Content.Server/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Server/Extinguisher/FireExtinguisherComponent.cs @@ -43,8 +43,7 @@ namespace Content.Server.Extinguisher var drained = targetSolution.Drain(trans); container.TryAddSolution(drained); - if(_refillSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _refillSound.GetSound(), Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("fire-extinguisher-component-after-interact-refilled-message",("owner", Owner))); } diff --git a/Content.Server/Flash/Components/FlashableComponent.cs b/Content.Server/Flash/Components/FlashableComponent.cs index 0653114aa7..f96d9c51a6 100644 --- a/Content.Server/Flash/Components/FlashableComponent.cs +++ b/Content.Server/Flash/Components/FlashableComponent.cs @@ -42,9 +42,9 @@ namespace Content.Server.Flash.Components flashable.Flash(duration); } - if (sound != null && sound.TryGetSound(out var soundName)) + if (sound != null) { - SoundSystem.Play(Filter.Pvs(source), soundName, source.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(source), sound.GetSound(), source.Transform.Coordinates); } } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 1e223aaed9..c40a09062b 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -92,8 +92,7 @@ namespace Content.Server.Flash }); } - if(comp.Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sound, comp.Owner.Transform.Coordinates, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.Sound.GetSound(), comp.Owner.Transform.Coordinates, AudioParams.Default); return true; } diff --git a/Content.Server/Fluids/Components/BucketComponent.cs b/Content.Server/Fluids/Components/BucketComponent.cs index 87709c52a8..2e7b3f771c 100644 --- a/Content.Server/Fluids/Components/BucketComponent.cs +++ b/Content.Server/Fluids/Components/BucketComponent.cs @@ -114,10 +114,7 @@ namespace Content.Server.Fluids.Components return false; } - if (_sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner); return true; } diff --git a/Content.Server/Fluids/Components/MopComponent.cs b/Content.Server/Fluids/Components/MopComponent.cs index 615bc5552a..379830be24 100644 --- a/Content.Server/Fluids/Components/MopComponent.cs +++ b/Content.Server/Fluids/Components/MopComponent.cs @@ -163,10 +163,7 @@ namespace Content.Server.Fluids.Components contents.SplitSolution(transferAmount); } - if (_pickupSound.TryGetSound(out var pickupSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), pickupSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _pickupSound.GetSound(), Owner); return true; } diff --git a/Content.Server/Fluids/Components/PuddleComponent.cs b/Content.Server/Fluids/Components/PuddleComponent.cs index 103b733267..9949856faf 100644 --- a/Content.Server/Fluids/Components/PuddleComponent.cs +++ b/Content.Server/Fluids/Components/PuddleComponent.cs @@ -190,8 +190,7 @@ namespace Content.Server.Fluids.Components return true; } - if(_spillSound.TryGetSound(out var spillSound)) - SoundSystem.Play(Filter.Pvs(Owner), spillSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _spillSound.GetSound(), Owner.Transform.Coordinates); return true; } diff --git a/Content.Server/Fluids/Components/SprayComponent.cs b/Content.Server/Fluids/Components/SprayComponent.cs index 1057df52d6..4824ffd6be 100644 --- a/Content.Server/Fluids/Components/SprayComponent.cs +++ b/Content.Server/Fluids/Components/SprayComponent.cs @@ -76,7 +76,7 @@ namespace Content.Server.Fluids.Components set => _sprayVelocity = value; } - [DataField("spraySound")] + [DataField("spraySound", required: true)] public SoundSpecifier SpraySound { get; } = default!; public ReagentUnit CurrentVolume => Owner.GetComponentOrNull()?.CurrentVolume ?? ReagentUnit.Zero; @@ -173,11 +173,7 @@ namespace Content.Server.Fluids.Components } } - //Play sound - if (SpraySound.TryGetSound(out var spraySound)) - { - SoundSystem.Play(Filter.Pvs(Owner), spraySound, Owner, AudioHelpers.WithVariation(0.125f)); - } + SoundSystem.Play(Filter.Pvs(Owner), SpraySound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); _lastUseTime = curTime; _cooldownEnd = _lastUseTime + TimeSpan.FromSeconds(_cooldownTime); diff --git a/Content.Server/GameTicking/Rules/RuleSuspicion.cs b/Content.Server/GameTicking/Rules/RuleSuspicion.cs index e1080ef625..130ddf8614 100644 --- a/Content.Server/GameTicking/Rules/RuleSuspicion.cs +++ b/Content.Server/GameTicking/Rules/RuleSuspicion.cs @@ -52,10 +52,9 @@ namespace Content.Server.GameTicking.Rules _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-suspicion-added-announcement")); var filter = Filter.Empty() - .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); + .AddWhere(session => ((IPlayerSession) session).ContentData()?.Mind?.HasRole() ?? false); - if(_addedSound.TryGetSound(out var addedSound)) - SoundSystem.Play(filter, addedSound, AudioParams.Default); + SoundSystem.Play(filter, _addedSound.GetSound(), AudioParams.Default); EntitySystem.Get().EndTime = _endTime; EntitySystem.Get().AccessType = DoorSystem.AccessTypes.AllowAllNoExternal; @@ -160,7 +159,7 @@ namespace Content.Server.GameTicking.Rules var gameTicker = EntitySystem.Get(); gameTicker.EndRound(text); - _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-restarting-in-seconds",("seconds", (int) RoundEndDelay.TotalSeconds))); + _chatManager.DispatchServerAnnouncement(Loc.GetString("rule-restarting-in-seconds", ("seconds", (int) RoundEndDelay.TotalSeconds))); _checkTimerCancel.Cancel(); Timer.Spawn(RoundEndDelay, () => gameTicker.RestartRound()); diff --git a/Content.Server/GameTicking/Rules/RuleTraitor.cs b/Content.Server/GameTicking/Rules/RuleTraitor.cs index ca697bc3d8..83d1df18c1 100644 --- a/Content.Server/GameTicking/Rules/RuleTraitor.cs +++ b/Content.Server/GameTicking/Rules/RuleTraitor.cs @@ -24,8 +24,7 @@ namespace Content.Server.GameTicking.Rules var filter = Filter.Empty() .AddWhere(session => ((IPlayerSession)session).ContentData()?.Mind?.HasRole() ?? false); - if(_addedSound.TryGetSound(out var addedSound)) - SoundSystem.Play(filter, addedSound, AudioParams.Default); + SoundSystem.Play(filter, _addedSound.GetSound(), AudioParams.Default); } } } diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index 92fa41fa92..3778b8a3c5 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -144,8 +144,7 @@ namespace Content.Server.Gravity.EntitySystems || player.AttachedEntity.Transform.GridID != gridId) continue; - if(comp.GravityShakeSound.TryGetSound(out var gravityShakeSound)) - SoundSystem.Play(Filter.Pvs(player.AttachedEntity), gravityShakeSound, player.AttachedEntity); + SoundSystem.Play(Filter.Pvs(player.AttachedEntity), comp.GravityShakeSound.GetSound(), player.AttachedEntity); } } diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index c6e2ac4896..daf034ddb6 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -143,8 +143,7 @@ namespace Content.Server.Hands.Components if (source != null) { - if(_disarmedSound.TryGetSound(out var disarmedSound)) - SoundSystem.Play(Filter.Pvs(source), disarmedSound, source, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); if (target != null) { diff --git a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs index eb15186f25..f4cb1e6022 100644 --- a/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs +++ b/Content.Server/Kitchen/Components/KitchenSpikeComponent.cs @@ -160,8 +160,7 @@ namespace Content.Server.Kitchen.Components // TODO: Need to be able to leave them on the spike to do DoT, see ss13. victim.Delete(); - if (SpikeSound.TryGetSound(out var spikeSound)) - SoundSystem.Play(Filter.Pvs(Owner), spikeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), SpikeSound.GetSound(), Owner); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 8737ad1159..a0786f7fe0 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -107,10 +107,10 @@ namespace Content.Server.Kitchen.Components switch (message.Message) { - case MicrowaveStartCookMessage msg : + case MicrowaveStartCookMessage msg: Wzhzhzh(); break; - case MicrowaveEjectMessage msg : + case MicrowaveEjectMessage msg: if (_hasContents) { VaporizeReagents(); @@ -271,7 +271,7 @@ namespace Content.Server.Kitchen.Components } Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-transfer-success", - ("amount",removedSolution.TotalVolume))); + ("amount", removedSolution.TotalVolume))); return true; } @@ -300,14 +300,14 @@ namespace Content.Server.Kitchen.Components _busy = true; // Convert storage into Dictionary of ingredients var solidsDict = new Dictionary(); - foreach(var item in _storage.ContainedEntities) + foreach (var item in _storage.ContainedEntities) { if (item.Prototype == null) { continue; } - if(solidsDict.ContainsKey(item.Prototype.ID)) + if (solidsDict.ContainsKey(item.Prototype.ID)) { solidsDict[item.Prototype.ID]++; } @@ -318,9 +318,9 @@ namespace Content.Server.Kitchen.Components } var failState = MicrowaveSuccessState.RecipeFail; - foreach(var id in solidsDict.Keys) + foreach (var id in solidsDict.Keys) { - if(_recipeManager.SolidAppears(id)) + if (_recipeManager.SolidAppears(id)) { continue; } @@ -337,43 +337,41 @@ namespace Content.Server.Kitchen.Components } SetAppearance(MicrowaveVisualState.Cooking); - if(_startCookingSound.TryGetSound(out var startCookingSound)) - SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default); - Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() => - { - if (_lostPower) - { - return; - } + SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default); + Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), (Action) (() => + { + if (_lostPower) + { + return; + } - if(failState == MicrowaveSuccessState.UnwantedForeignObject) - { - VaporizeReagents(); - EjectSolids(); - } - else - { - if (recipeToCook != null) - { - SubtractContents(recipeToCook); - Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); - } - else - { - VaporizeReagents(); - VaporizeSolids(); - Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); - } - } + if (failState == MicrowaveSuccessState.UnwantedForeignObject) + { + VaporizeReagents(); + EjectSolids(); + } + else + { + if (recipeToCook != null) + { + SubtractContents(recipeToCook); + Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates); + } + else + { + VaporizeReagents(); + VaporizeSolids(); + Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates); + } + } - if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound)) - SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f)); + SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, AudioParams.Default.WithVolume(-1f)); - SetAppearance(MicrowaveVisualState.Idle); - _busy = false; + SetAppearance(MicrowaveVisualState.Idle); + _busy = false; - _uiDirty = true; - })); + _uiDirty = true; + })); _lostPower = false; _uiDirty = true; } @@ -396,7 +394,7 @@ namespace Content.Server.Kitchen.Components private void VaporizeSolids() { - for(var i = _storage.ContainedEntities.Count-1; i>=0; i--) + for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) { var item = _storage.ContainedEntities.ElementAt(i); _storage.Remove(item); @@ -407,7 +405,7 @@ namespace Content.Server.Kitchen.Components private void EjectSolids() { - for(var i = _storage.ContainedEntities.Count-1; i>=0; i--) + for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--) { _storage.Remove(_storage.ContainedEntities.ElementAt(i)); } @@ -429,7 +427,7 @@ namespace Content.Server.Kitchen.Components return; } - foreach(var recipeReagent in recipe.IngredientsReagents) + foreach (var recipeReagent in recipe.IngredientsReagents) { solution?.TryRemoveReagent(recipeReagent.Key, ReagentUnit.New(recipeReagent.Value)); } @@ -457,7 +455,7 @@ namespace Content.Server.Kitchen.Components } - private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids) + private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary solids) { if (_currentCookTimerTime != (uint) recipe.CookTime) { @@ -500,8 +498,7 @@ namespace Content.Server.Kitchen.Components private void ClickSound() { - if(_clickSound.TryGetSound(out var clickSound)) - SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat) @@ -537,7 +534,7 @@ namespace Content.Server.Kitchen.Components var othersMessage = headCount > 1 ? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim)) - : Loc.GetString("microwave-component-suicide-others-message",("victim", victim)); + : Loc.GetString("microwave-component-suicide-others-message", ("victim", victim)); victim.PopupMessageOtherClients(othersMessage); diff --git a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs index 5507978b53..51cc7b0b1d 100644 --- a/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs +++ b/Content.Server/Kitchen/Components/ReagentGrinderComponent.cs @@ -39,8 +39,8 @@ namespace Content.Server.Kitchen.Components //YAML serialization vars [ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] public int StorageCap = 16; [ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] public 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"); + [DataField("clickSound")] public SoundSpecifier ClickSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg"); + [DataField("grindSound")] public SoundSpecifier GrindSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/blender.ogg"); + [DataField("juiceSound")] public SoundSpecifier JuiceSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/juicer.ogg"); } } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 2b110578c1..74a128539c 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Content.Server.Chemistry.Components; @@ -270,7 +270,7 @@ namespace Content.Server.Kitchen.EntitySystems switch (program) { case SharedReagentGrinderComponent.GrinderProgram.Grind: - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/blender.ogg", component.Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(component.Owner), component.GrindSound.GetSound(), component.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. component.Owner.SpawnTimer(component.WorkTime, (Action) (() => { @@ -291,7 +291,7 @@ namespace Content.Server.Kitchen.EntitySystems break; case SharedReagentGrinderComponent.GrinderProgram.Juice: - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/juicer.ogg", component.Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(component.Owner), component.JuiceSound.GetSound(), component.Owner, AudioParams.Default); component.Owner.SpawnTimer(component.WorkTime, (Action) (() => { foreach (var item in component.Chamber.ContainedEntities.ToList()) @@ -311,7 +311,7 @@ namespace Content.Server.Kitchen.EntitySystems private void ClickSound(ReagentGrinderComponent component) { - SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/machine_switch.ogg", component.Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(component.Owner), component.ClickSound.GetSound(), component.Owner, AudioParams.Default.WithVolume(-2f)); } } } diff --git a/Content.Server/Light/Components/ExpendableLightComponent.cs b/Content.Server/Light/Components/ExpendableLightComponent.cs index 87a098f66d..b60bf0f8b2 100644 --- a/Content.Server/Light/Components/ExpendableLightComponent.cs +++ b/Content.Server/Light/Components/ExpendableLightComponent.cs @@ -100,11 +100,8 @@ namespace Content.Server.Light.Components switch (CurrentState) { case ExpendableLightState.Lit: - if (LitSound.TryGetSound(out var litSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), litSound, Owner); - } - + SoundSystem.Play(Filter.Pvs(Owner), LitSound.GetSound(), Owner); + if (IconStateLit != string.Empty) { sprite.LayerSetState(2, IconStateLit); @@ -119,11 +116,7 @@ namespace Content.Server.Light.Components default: case ExpendableLightState.Dead: - - if (DieSound.TryGetSound(out var dieSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), dieSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), DieSound.GetSound(), Owner); sprite.LayerSetState(0, IconStateSpent); sprite.LayerSetShader(0, "shaded"); diff --git a/Content.Server/Light/Components/HandheldLightComponent.cs b/Content.Server/Light/Components/HandheldLightComponent.cs index 35f5e43eee..2db579e71c 100644 --- a/Content.Server/Light/Components/HandheldLightComponent.cs +++ b/Content.Server/Light/Components/HandheldLightComponent.cs @@ -120,9 +120,9 @@ namespace Content.Server.Light.Components UpdateLightAction(); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new DeactivateHandheldLightMessage(this)); - if (makeNoise && TurnOffSound.TryGetSound(out var turnOffSound)) + if (makeNoise) { - SoundSystem.Play(Filter.Pvs(Owner), turnOffSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound.GetSound(), Owner); } return true; @@ -137,8 +137,7 @@ namespace Content.Server.Light.Components if (Cell == null) { - if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-missing-message")); UpdateLightAction(); return false; @@ -149,8 +148,7 @@ namespace Content.Server.Light.Components // Simple enough. if (Wattage > Cell.CurrentCharge) { - if (TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnFailSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnFailSound.GetSound(), Owner); Owner.PopupMessage(user, Loc.GetString("handheld-light-component-cell-dead-message")); UpdateLightAction(); return false; @@ -161,8 +159,7 @@ namespace Content.Server.Light.Components SetState(true); Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this)); - if (TurnOnSound.TryGetSound(out var turnOnSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound.GetSound(), Owner); return true; } diff --git a/Content.Server/Light/Components/LightBulbComponent.cs b/Content.Server/Light/Components/LightBulbComponent.cs index 6cc8253324..342dc41303 100644 --- a/Content.Server/Light/Components/LightBulbComponent.cs +++ b/Content.Server/Light/Components/LightBulbComponent.cs @@ -47,7 +47,8 @@ namespace Content.Server.Light.Components [DataField("color")] private Color _color = Color.White; - [ViewVariables(VVAccess.ReadWrite)] public Color Color + [ViewVariables(VVAccess.ReadWrite)] + public Color Color { get { return _color; } set @@ -78,7 +79,8 @@ namespace Content.Server.Light.Components /// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set. /// It also updates the bulb's sprite accordingly. /// - [ViewVariables(VVAccess.ReadWrite)] public LightBulbState State + [ViewVariables(VVAccess.ReadWrite)] + public LightBulbState State { get { return _state; } set @@ -132,8 +134,7 @@ namespace Content.Server.Light.Components public void PlayBreakSound() { - if(_breakSound.TryGetSound(out var breakSound)) - SoundSystem.Play(Filter.Pvs(Owner), breakSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _breakSound.GetSound(), Owner); } } } diff --git a/Content.Server/Light/Components/MatchstickComponent.cs b/Content.Server/Light/Components/MatchstickComponent.cs index 3cba208db5..864ed2ae1a 100644 --- a/Content.Server/Light/Components/MatchstickComponent.cs +++ b/Content.Server/Light/Components/MatchstickComponent.cs @@ -24,13 +24,14 @@ namespace Content.Server.Light.Components /// /// How long will matchstick last in seconds. /// - [ViewVariables(VVAccess.ReadOnly)] [DataField("duration")] + [ViewVariables(VVAccess.ReadOnly)] + [DataField("duration")] private int _duration = 10; /// /// Sound played when you ignite the matchstick. /// - [DataField("igniteSound")] private SoundSpecifier _igniteSound = default!; + [DataField("igniteSound", required: true)] private SoundSpecifier _igniteSound = default!; /// /// Point light component. Gives matches a glow in dark effect. @@ -69,11 +70,9 @@ namespace Content.Server.Light.Components public void Ignite(IEntity user) { // Play Sound - if (_igniteSound.TryGetSound(out var igniteSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), igniteSound, Owner, - AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); - } + SoundSystem.Play( + Filter.Pvs(Owner), _igniteSound.GetSound(), Owner, + AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f)); // Change state CurrentState = SharedBurningStates.Lit; diff --git a/Content.Server/Light/Components/PoweredLightComponent.cs b/Content.Server/Light/Components/PoweredLightComponent.cs index d63f34c093..5f38eda681 100644 --- a/Content.Server/Light/Components/PoweredLightComponent.cs +++ b/Content.Server/Light/Components/PoweredLightComponent.cs @@ -58,7 +58,8 @@ namespace Content.Server.Light.Components [DataField("hasLampOnSpawn")] private bool _hasLampOnSpawn = true; - [ViewVariables] [DataField("on")] + [ViewVariables] + [DataField("on")] private bool _on = true; [ViewVariables] @@ -67,7 +68,8 @@ namespace Content.Server.Light.Components [ViewVariables] private bool _isBlinking; - [ViewVariables] [DataField("ignoreGhostsBoo")] + [ViewVariables] + [DataField("ignoreGhostsBoo")] private bool _ignoreGhostsBoo; [DataField("bulb")] private LightBulbType _bulbType = LightBulbType.Tube; @@ -102,9 +104,9 @@ namespace Content.Server.Light.Components Eject(); return false; } - if(eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent)) + if (eventArgs.User.TryGetComponent(out HeatResistanceComponent? heatResistanceComponent)) { - if(CanBurn(heatResistanceComponent.GetHeatResistance())) + if (CanBurn(heatResistanceComponent.GetHeatResistance())) { Burn(); return true; @@ -125,8 +127,7 @@ namespace Content.Server.Light.Components { Owner.PopupMessage(eventArgs.User, Loc.GetString("powered-light-component-burn-hand")); damageableComponent.ChangeDamage(DamageType.Heat, 20, false, Owner); - if(_burnHandSound.TryGetSound(out var burnHandSound)) - SoundSystem.Play(Filter.Pvs(Owner), burnHandSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _burnHandSound.GetSound(), Owner); } void Eject() @@ -228,8 +229,7 @@ namespace Content.Server.Light.Components if (time > _lastThunk + _thunkDelay) { _lastThunk = time; - if(_turnOnSound.TryGetSound(out var turnOnSound)) - SoundSystem.Play(Filter.Pvs(Owner), turnOnSound, Owner, AudioParams.Default.WithVolume(-10f)); + SoundSystem.Play(Filter.Pvs(Owner), _turnOnSound.GetSound(), Owner, AudioParams.Default.WithVolume(-10f)); } } else @@ -338,7 +338,8 @@ namespace Content.Server.Light.Components _lastGhostBlink = time; ToggleBlinkingLight(true); - Owner.SpawnTimer(ghostBlinkingTime, () => { + Owner.SpawnTimer(ghostBlinkingTime, () => + { ToggleBlinkingLight(false); }); diff --git a/Content.Server/Lock/LockComponent.cs b/Content.Server/Lock/LockComponent.cs index 966548e607..ad9f25afe8 100644 --- a/Content.Server/Lock/LockComponent.cs +++ b/Content.Server/Lock/LockComponent.cs @@ -20,8 +20,8 @@ namespace Content.Server.Storage.Components public override string Name => "Lock"; [ViewVariables(VVAccess.ReadWrite)] [DataField("locked")] public bool Locked { get; set; } = true; - [ViewVariables(VVAccess.ReadWrite)] [DataField("unlockingSound")] public SoundSpecifier? UnlockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); - [ViewVariables(VVAccess.ReadWrite)] [DataField("lockingSound")] public SoundSpecifier? LockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("unlockingSound")] public SoundSpecifier UnlockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); + [ViewVariables(VVAccess.ReadWrite)] [DataField("lockingSound")] public SoundSpecifier LockSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/door_lock_off.ogg"); [Verb] private sealed class ToggleLockVerb : Verb diff --git a/Content.Server/Mining/Components/AsteroidRockComponent.cs b/Content.Server/Mining/Components/AsteroidRockComponent.cs index 246f49ceee..4de41b4275 100644 --- a/Content.Server/Mining/Components/AsteroidRockComponent.cs +++ b/Content.Server/Mining/Components/AsteroidRockComponent.cs @@ -42,10 +42,7 @@ namespace Content.Server.Mining.Components if (!item.TryGetComponent(out PickaxeComponent? pickaxeComponent)) return true; - if (pickaxeComponent.MiningSound.TryGetSound(out var miningSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), miningSound, Owner, AudioParams.Default); - } + SoundSystem.Play(Filter.Pvs(Owner), pickaxeComponent.MiningSound.GetSound(), Owner, AudioParams.Default); return true; } } diff --git a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs index 0366a29034..11f8b81b44 100644 --- a/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/CrematoriumEntityStorageComponent.cs @@ -120,8 +120,7 @@ namespace Content.Server.Morgue.Components TryOpenStorage(Owner); - if (_cremateFinishSound.TryGetSound(out var cremateFinishSound)) - SoundSystem.Play(Filter.Pvs(Owner), cremateFinishSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _cremateFinishSound.GetSound(), Owner); }, _cremateCancelToken.Token); } diff --git a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs index b03ef06737..d61e8683bb 100644 --- a/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs +++ b/Content.Server/Morgue/Components/MorgueEntityStorageComponent.cs @@ -146,10 +146,9 @@ namespace Content.Server.Morgue.Components { CheckContents(); - if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul && - _occupantHasSoulAlarmSound.TryGetSound(out var occupantHasSoulAlarmSound)) + if (DoSoulBeep && Appearance != null && Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) { - SoundSystem.Play(Filter.Pvs(Owner), occupantHasSoulAlarmSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _occupantHasSoulAlarmSound.GetSound(), Owner); } } diff --git a/Content.Server/Movement/Components/FootstepModifierComponent.cs b/Content.Server/Movement/Components/FootstepModifierComponent.cs index c61ec76cc3..9384c7d730 100644 --- a/Content.Server/Movement/Components/FootstepModifierComponent.cs +++ b/Content.Server/Movement/Components/FootstepModifierComponent.cs @@ -15,13 +15,12 @@ namespace Content.Server.Movement.Components /// public override string Name => "FootstepModifier"; - [DataField("footstepSoundCollection")] - public SoundSpecifier _soundCollection = default!; + [DataField("footstepSoundCollection", required: true)] + public SoundSpecifier SoundCollection = default!; public void PlayFootstep() { - if (_soundCollection.TryGetSound(out var footstepSound)) - SoundSystem.Play(Filter.Pvs(Owner), footstepSound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), SoundCollection.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2f)); } } } diff --git a/Content.Server/Nutrition/Components/CreamPieComponent.cs b/Content.Server/Nutrition/Components/CreamPieComponent.cs index e59a084fe5..97b46fd83a 100644 --- a/Content.Server/Nutrition/Components/CreamPieComponent.cs +++ b/Content.Server/Nutrition/Components/CreamPieComponent.cs @@ -25,8 +25,7 @@ namespace Content.Server.Nutrition.Components public void PlaySound() { - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs) diff --git a/Content.Server/Nutrition/Components/DrinkComponent.cs b/Content.Server/Nutrition/Components/DrinkComponent.cs index 40f783d299..0a1a9fc39c 100644 --- a/Content.Server/Nutrition/Components/DrinkComponent.cs +++ b/Content.Server/Nutrition/Components/DrinkComponent.cs @@ -127,8 +127,7 @@ namespace Content.Server.Nutrition.Components if (!Opened) { //Do the opening stuff like playing the sounds. - if(_openSounds.TryGetSound(out var openSound)) - SoundSystem.Play(Filter.Pvs(args.User), openSound, args.User, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(args.User), _openSounds.GetSound(), args.User, AudioParams.Default); Opened = true; return false; @@ -137,7 +136,7 @@ namespace Content.Server.Nutrition.Components if (!Owner.TryGetComponent(out ISolutionInteractionsComponent? contents) || contents.DrainAvailable <= 0) { - args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty",("owner", Owner))); + args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty", ("owner", Owner))); return true; } @@ -163,14 +162,14 @@ namespace Content.Server.Nutrition.Components } var color = Empty ? "gray" : "yellow"; var openedText = Loc.GetString(Empty ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened"); - message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text",("colorName", color),("text", openedText))); + message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))); } private bool TryUseDrink(IEntity user, IEntity target, bool forced = false) { if (!Opened) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open", ("owner", Owner))); return false; } @@ -180,7 +179,7 @@ namespace Content.Server.Nutrition.Components { if (!forced) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity",Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity", Owner))); } return false; @@ -189,7 +188,7 @@ namespace Content.Server.Nutrition.Components if (!target.TryGetComponent(out SharedBodyComponent? body) || !body.TryGetMechanismBehaviors(out var stomachs)) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink", ("owner", Owner))); return false; } @@ -207,7 +206,7 @@ namespace Content.Server.Nutrition.Components // All stomach are full or can't handle whatever solution we have. if (firstStomach == null) { - target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough",("owner", Owner))); + target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough", ("owner", Owner))); if (!interactions.CanRefill) { @@ -219,10 +218,7 @@ namespace Content.Server.Nutrition.Components return false; } - if (_useSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(target), useSound, target, AudioParams.Default.WithVolume(-2f)); - } + SoundSystem.Play(Filter.Pvs(target), _useSound.GetSound(), target, AudioParams.Default.WithVolume(-2f)); target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp")); UpdateAppearance(); @@ -253,8 +249,7 @@ namespace Content.Server.Nutrition.Components var solution = interactions.Drain(interactions.DrainAvailable); solution.SpillAt(Owner, "PuddleSmear"); - if(_burstSound.TryGetSound(out var burstSound)) - SoundSystem.Play(Filter.Pvs(Owner), burstSound, Owner, AudioParams.Default.WithVolume(-4)); + SoundSystem.Play(Filter.Pvs(Owner), _burstSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4)); } } } diff --git a/Content.Server/Nutrition/Components/FoodComponent.cs b/Content.Server/Nutrition/Components/FoodComponent.cs index 8a6afa4ffc..08c9cdbad6 100644 --- a/Content.Server/Nutrition/Components/FoodComponent.cs +++ b/Content.Server/Nutrition/Components/FoodComponent.cs @@ -50,7 +50,7 @@ namespace Content.Server.Nutrition.Components return solution.CurrentVolume == 0 ? 0 - : Math.Max(1, (int)Math.Ceiling((solution.CurrentVolume / TransferAmount).Float())); + : Math.Max(1, (int) Math.Ceiling((solution.CurrentVolume / TransferAmount).Float())); } } @@ -110,7 +110,7 @@ namespace Content.Server.Nutrition.Components } var utensils = utensilUsed != null - ? new List {utensilUsed} + ? new List { utensilUsed } : null; if (_utensilsNeeded != UtensilType.None) @@ -160,10 +160,7 @@ namespace Content.Server.Nutrition.Components firstStomach.TryTransferSolution(split); - if (UseSound.TryGetSound(out var useSound)) - { - SoundSystem.Play(Filter.Pvs(trueTarget), useSound, trueTarget, AudioParams.Default.WithVolume(-1f)); - } + SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f)); trueTarget.PopupMessage(user, Loc.GetString("food-nom")); diff --git a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs index cc1f4502e2..6f707b3daa 100644 --- a/Content.Server/Nutrition/Components/SliceableFoodComponent.cs +++ b/Content.Server/Nutrition/Components/SliceableFoodComponent.cs @@ -24,13 +24,16 @@ namespace Content.Server.Nutrition.Components int IInteractUsing.Priority => 1; // take priority over eating with utensils - [DataField("slice")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("slice")] + [ViewVariables(VVAccess.ReadWrite)] private string _slice = string.Empty; - [DataField("sound")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("sound")] + [ViewVariables(VVAccess.ReadWrite)] private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Items/Culinary/chop.ogg"); - [DataField("count")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("count")] + [ViewVariables(VVAccess.ReadWrite)] private ushort _totalCount = 5; [ViewVariables(VVAccess.ReadWrite)] public ushort Count; @@ -67,9 +70,8 @@ namespace Content.Server.Nutrition.Components } } - if(_sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, - AudioParams.Default.WithVolume(-2)); + SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner.Transform.Coordinates, + AudioParams.Default.WithVolume(-2)); Count--; if (Count < 1) diff --git a/Content.Server/Nutrition/Components/UtensilComponent.cs b/Content.Server/Nutrition/Components/UtensilComponent.cs index c31599d193..5275a313ed 100644 --- a/Content.Server/Nutrition/Components/UtensilComponent.cs +++ b/Content.Server/Nutrition/Components/UtensilComponent.cs @@ -71,9 +71,9 @@ namespace Content.Server.Nutrition.Components internal void TryBreak(IEntity user) { - if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve().Prob(_breakChance)) + if (IoCManager.Resolve().Prob(_breakChance)) { - SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(user), _breakSound.GetSound(), user, AudioParams.Default.WithVolume(-2f)); Owner.Delete(); } } diff --git a/Content.Server/PDA/PDAComponent.cs b/Content.Server/PDA/PDAComponent.cs index 2c392f91a0..a2ffba3a95 100644 --- a/Content.Server/PDA/PDAComponent.cs +++ b/Content.Server/PDA/PDAComponent.cs @@ -104,49 +104,49 @@ namespace Content.Server.PDA switch (message.Message) { case PDARequestUpdateInterfaceMessage _: - { - UpdatePDAUserInterface(); - break; - } - case PDAToggleFlashlightMessage _: - { - ToggleLight(); - break; - } - - case PDAEjectIDMessage _: - { - HandleIDEjection(message.Session.AttachedEntity!); - break; - } - - case PDAEjectPenMessage _: - { - HandlePenEjection(message.Session.AttachedEntity!); - break; - } - - case PDAUplinkBuyListingMessage buyMsg: - { - var player = message.Session.AttachedEntity; - if (player == null) - break; - - if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, - player.Transform.Coordinates, out var entity)) { - SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); + UpdatePDAUserInterface(); + break; + } + case PDAToggleFlashlightMessage _: + { + ToggleLight(); break; } - if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item)) + case PDAEjectIDMessage _: + { + HandleIDEjection(message.Session.AttachedEntity!); break; + } - hands.PutInHandOrDrop(item); + case PDAEjectPenMessage _: + { + HandlePenEjection(message.Session.AttachedEntity!); + break; + } - SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); - break; - } + case PDAUplinkBuyListingMessage buyMsg: + { + var player = message.Session.AttachedEntity; + if (player == null) + break; + + if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId, + player.Transform.Coordinates, out var entity)) + { + SendNetworkMessage(new PDAUplinkInsufficientFundsMessage(), message.Session.ConnectedClient); + break; + } + + if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item)) + break; + + hands.PutInHandOrDrop(item); + + SendNetworkMessage(new PDAUplinkBuySuccessMessage(), message.Session.ConnectedClient); + break; + } } } @@ -305,8 +305,7 @@ namespace Content.Server.PDA { _idSlot.Insert(card.Owner); ContainedID = card; - if(_insertIdSound.TryGetSound(out var insertIdSound)) - SoundSystem.Play(Filter.Pvs(Owner), insertIdSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _insertIdSound.GetSound(), Owner); } /// @@ -335,8 +334,7 @@ namespace Content.Server.PDA _lightOn = !_lightOn; light.Enabled = _lightOn; - if(_toggleFlashlightSound.TryGetSound(out var toggleFlashlightSound)) - SoundSystem.Play(Filter.Pvs(Owner), toggleFlashlightSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _toggleFlashlightSound.GetSound(), Owner); UpdatePDAUserInterface(); } @@ -355,8 +353,7 @@ namespace Content.Server.PDA hands.PutInHandOrDrop(cardItemComponent); ContainedID = null; - if(_ejectIdSound.TryGetSound(out var ejectIdSound)) - SoundSystem.Play(Filter.Pvs(Owner), ejectIdSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _ejectIdSound.GetSound(), Owner); UpdatePDAUserInterface(); } diff --git a/Content.Server/Physics/Controllers/MoverController.cs b/Content.Server/Physics/Controllers/MoverController.cs index 5c97878c3e..386a79af1f 100644 --- a/Content.Server/Physics/Controllers/MoverController.cs +++ b/Content.Server/Physics/Controllers/MoverController.cs @@ -214,10 +214,9 @@ namespace Content.Server.Physics.Controllers string? soundToPlay = null; foreach (var maybeFootstep in grid.GetAnchoredEntities(tile.GridIndices)) { - if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep) && - footstep._soundCollection.TryGetSound(out var footstepSound)) + if (EntityManager.ComponentManager.TryGetComponent(maybeFootstep, out FootstepModifierComponent? footstep)) { - soundToPlay = footstepSound; + soundToPlay = footstep.SoundCollection.GetSound(); break; } } @@ -226,11 +225,8 @@ namespace Content.Server.Physics.Controllers { // Walking on a tile. var def = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId]; - if (def.FootstepSounds.TryGetSound(out var footstepSound)) - { - soundToPlay = footstepSound; - return; - } + soundToPlay = def.FootstepSounds.GetSound(); + return; } if (string.IsNullOrWhiteSpace(soundToPlay)) diff --git a/Content.Server/Plants/Components/PottedPlantHideComponent.cs b/Content.Server/Plants/Components/PottedPlantHideComponent.cs index 2a64e494c4..ecab584ba2 100644 --- a/Content.Server/Plants/Components/PottedPlantHideComponent.cs +++ b/Content.Server/Plants/Components/PottedPlantHideComponent.cs @@ -49,8 +49,7 @@ namespace Content.Server.Plants.Components private void Rustle() { - if(_rustleSound.TryGetSound(out var rustleSound)) - SoundSystem.Play(Filter.Pvs(Owner), rustleSound, Owner, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(Owner), _rustleSound.GetSound(), Owner, AudioHelpers.WithVariation(0.25f)); } } } diff --git a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs index da3014d516..f800134a8a 100644 --- a/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs +++ b/Content.Server/Pointing/Components/RoguePointingArrowComponent.cs @@ -123,8 +123,7 @@ namespace Content.Server.Pointing.Components } Owner.SpawnExplosion(0, 2, 1, 1); - if(_explosionSound.TryGetSound(out var explosionSound)) - SoundSystem.Play(Filter.Pvs(Owner), explosionSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _explosionSound.GetSound(), Owner); Owner.Delete(); } diff --git a/Content.Server/Power/Components/ApcComponent.cs b/Content.Server/Power/Components/ApcComponent.cs index 442cdb8756..987dd2c16d 100644 --- a/Content.Server/Power/Components/ApcComponent.cs +++ b/Content.Server/Power/Components/ApcComponent.cs @@ -85,7 +85,7 @@ namespace Content.Server.Power.Components if (serverMsg.Message is ApcToggleMainBreakerMessage) { var user = serverMsg.Session.AttachedEntity; - if(user == null) return; + if (user == null) return; if (_accessReader == null || _accessReader.IsAllowed(user)) { @@ -93,8 +93,7 @@ namespace Content.Server.Power.Components Owner.GetComponent().CanDischarge = MainBreakerEnabled; _uiDirty = true; - if(_onReceiveMessageSound.TryGetSound(out var onReceiveMessageSound)) - SoundSystem.Play(Filter.Pvs(Owner), onReceiveMessageSound, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } else { diff --git a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs index bf8f694779..97decb4d4f 100644 --- a/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs +++ b/Content.Server/PowerCell/Components/PowerCellSlotComponent.cs @@ -144,9 +144,9 @@ namespace Content.Server.PowerCell.Components cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates; } - if (playSound && CellRemoveSound.TryGetSound(out var cellRemoveSound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(Owner), cellRemoveSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), CellRemoveSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(true), false); @@ -167,9 +167,9 @@ namespace Content.Server.PowerCell.Components if (cellComponent.CellSize != SlotSize) return false; if (!_cellContainer.Insert(cell)) return false; //Dirty(); - if (playSound && CellInsertSound.TryGetSound(out var cellInsertSound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(Owner), cellInsertSound, Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(Owner), CellInsertSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); } Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PowerCellChangedEvent(false), false); diff --git a/Content.Server/Projectiles/Components/HitscanComponent.cs b/Content.Server/Projectiles/Components/HitscanComponent.cs index 073ed091e6..721aac12ab 100644 --- a/Content.Server/Projectiles/Components/HitscanComponent.cs +++ b/Content.Server/Projectiles/Components/HitscanComponent.cs @@ -86,8 +86,7 @@ namespace Content.Server.Projectiles.Components // TODO: No wall component so ? var offset = angle.ToVec().Normalized / 2; var coordinates = user.Transform.Coordinates.Offset(offset); - if(_soundHitWall.TryGetSound(out var soundHitWall)) - SoundSystem.Play(Filter.Pvs(coordinates), soundHitWall, coordinates); + SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall.GetSound(), coordinates); } Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () => diff --git a/Content.Server/Projectiles/Components/ProjectileComponent.cs b/Content.Server/Projectiles/Components/ProjectileComponent.cs index 64a56ef03a..c22f5038a0 100644 --- a/Content.Server/Projectiles/Components/ProjectileComponent.cs +++ b/Content.Server/Projectiles/Components/ProjectileComponent.cs @@ -26,8 +26,8 @@ namespace Content.Server.Projectiles.Components public bool DeleteOnCollide { get; } = true; // Get that juicy FPS hit sound - [DataField("soundHit")] public SoundSpecifier SoundHit = default!; - [DataField("soundHitSpecies")] public SoundSpecifier SoundHitSpecies = default!; + [DataField("soundHit", required: true)] public SoundSpecifier SoundHit = default!; + [DataField("soundHitSpecies", required: true)] public SoundSpecifier SoundHitSpecies = default!; public bool DamagedEntity; diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 76b1b7c32a..d5bf5173a1 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -32,14 +32,13 @@ namespace Content.Server.Projectiles var coordinates = args.OtherFixture.Body.Owner.Transform.Coordinates; var playerFilter = Filter.Pvs(coordinates); - if (!otherEntity.Deleted && - otherEntity.HasComponent() && component.SoundHitSpecies.TryGetSound(out var soundHitSpecies)) + if (!otherEntity.Deleted && otherEntity.HasComponent()) { - SoundSystem.Play(playerFilter, soundHitSpecies, coordinates); + SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates); } - else if (component.SoundHit.TryGetSound(out var soundHit)) + else { - SoundSystem.Play(playerFilter, soundHit, coordinates); + SoundSystem.Play(playerFilter, component.SoundHit.GetSound(), coordinates); } if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage)) diff --git a/Content.Server/RCD/Components/RCDComponent.cs b/Content.Server/RCD/Components/RCDComponent.cs index bde50fec51..3479d667b0 100644 --- a/Content.Server/RCD/Components/RCDComponent.cs +++ b/Content.Server/RCD/Components/RCDComponent.cs @@ -33,7 +33,7 @@ namespace Content.Server.RCD.Components public override string Name => "RCD"; private RcdMode _mode = 0; //What mode are we on? Can be floors, walls, deconstruct. - private readonly RcdMode[] _modes = (RcdMode[]) Enum.GetValues(typeof(RcdMode)); + private readonly RcdMode[] _modes = (RcdMode[]) Enum.GetValues(typeof(RcdMode)); [ViewVariables(VVAccess.ReadWrite)] [DataField("maxAmmo")] public int MaxAmmo = 5; public int _ammo; //How much "ammo" we have left. You can refill this with RCD ammo. [ViewVariables(VVAccess.ReadWrite)] [DataField("delay")] private float _delay = 2f; @@ -77,8 +77,7 @@ namespace Content.Server.RCD.Components public void SwapMode(UseEntityEventArgs eventArgs) { - if(_swapModeSound.TryGetSound(out var swapModeSound)) - SoundSystem.Play(Filter.Pvs(Owner), swapModeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _swapModeSound.GetSound(), 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 = (RcdMode) mode; //Finally, cast the newly acquired int mode to an RCDmode so we can use it. @@ -104,7 +103,7 @@ namespace Content.Server.RCD.Components } } - async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) + async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) { // FIXME: Make this work properly. Right now it relies on the click location being on a grid, which is bad. if (!eventArgs.ClickLocation.IsValid(Owner.EntityManager) || !eventArgs.ClickLocation.GetGridId(Owner.EntityManager).IsValid()) @@ -163,8 +162,7 @@ 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! } - if(_successSound.TryGetSound(out var successSound)) - SoundSystem.Play(Filter.Pvs(Owner), successSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _successSound.GetSound(), Owner); _ammo--; return true; } diff --git a/Content.Server/Radiation/RadiationPulseComponent.cs b/Content.Server/Radiation/RadiationPulseComponent.cs index e5851f600e..143b5bf87d 100644 --- a/Content.Server/Radiation/RadiationPulseComponent.cs +++ b/Content.Server/Radiation/RadiationPulseComponent.cs @@ -93,8 +93,7 @@ namespace Content.Server.Radiation _endTime = currentTime + TimeSpan.FromSeconds(_duration); } - if(Sound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), Sound.GetSound(), Owner.Transform.Coordinates); Dirty(); } @@ -109,7 +108,7 @@ namespace Content.Server.Radiation if (!Decay || Owner.Deleted) return; - if(_duration <= 0f) + if (_duration <= 0f) Owner.QueueDelete(); _duration -= frameTime; diff --git a/Content.Server/Research/Components/ResearchConsoleComponent.cs b/Content.Server/Research/Components/ResearchConsoleComponent.cs index 3a94d9a311..7615259fcd 100644 --- a/Content.Server/Research/Components/ResearchConsoleComponent.cs +++ b/Content.Server/Research/Components/ResearchConsoleComponent.cs @@ -125,8 +125,7 @@ namespace Content.Server.Research.Components private void PlayKeyboardSound() { - if (_soundCollectionName.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), _soundCollectionName.GetSound(), Owner, AudioParams.Default); } } } diff --git a/Content.Server/Singularity/Components/ServerSingularityComponent.cs b/Content.Server/Singularity/Components/ServerSingularityComponent.cs index 9874b82030..9a75e0673a 100644 --- a/Content.Server/Singularity/Components/ServerSingularityComponent.cs +++ b/Content.Server/Singularity/Components/ServerSingularityComponent.cs @@ -89,9 +89,8 @@ namespace Content.Server.Singularity.Components audioParams.Loop = true; audioParams.MaxDistance = 20f; audioParams.Volume = 5; - if(_singularityFormingSound.TryGetSound(out var singuloFormingSound)) - SoundSystem.Play(Filter.Pvs(Owner), singuloFormingSound, Owner); - Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams)); + SoundSystem.Play(Filter.Pvs(Owner), _singularityFormingSound.GetSound(), Owner); + Timer.Spawn(5200, () => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), _singularitySound.GetSound(), Owner, audioParams)); _singularitySystem.ChangeSingularityLevel(this, 1); } @@ -104,8 +103,7 @@ namespace Content.Server.Singularity.Components protected override void OnRemove() { _playingSound?.Stop(); - if(_singularityCollapsingSound.TryGetSound(out var singuloCollapseSound)) - SoundSystem.Play(Filter.Pvs(Owner), singuloCollapseSound, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), Owner.Transform.Coordinates); base.OnRemove(); } } diff --git a/Content.Server/Slippery/SlipperySystem.cs b/Content.Server/Slippery/SlipperySystem.cs index 278ffc6d10..31fe94ebe5 100644 --- a/Content.Server/Slippery/SlipperySystem.cs +++ b/Content.Server/Slippery/SlipperySystem.cs @@ -9,10 +9,7 @@ namespace Content.Server.Slippery { protected override void PlaySound(SlipperyComponent component) { - if (component.SlipSound.TryGetSound(out var slipSound)) - { - SoundSystem.Play(Filter.Pvs(component.Owner), slipSound, component.Owner, AudioHelpers.WithVariation(0.2f)); - } + SoundSystem.Play(Filter.Pvs(component.Owner), component.SlipSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.2f)); } } } diff --git a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs index 6b9ee8ff75..ec2e85800c 100644 --- a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs +++ b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs @@ -12,7 +12,7 @@ namespace Content.Server.Sound.Components public abstract class BaseEmitSoundComponent : Component { [ViewVariables(VVAccess.ReadWrite)] - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier Sound { get; set; } = default!; [ViewVariables(VVAccess.ReadWrite)] diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs index e397d51d01..46b8b9bc8b 100644 --- a/Content.Server/Sound/EmitSoundSystem.cs +++ b/Content.Server/Sound/EmitSoundSystem.cs @@ -7,7 +7,6 @@ using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.GameObjects; -using Robust.Shared.Log; using Robust.Shared.Player; namespace Content.Server.Sound @@ -50,14 +49,7 @@ namespace Content.Server.Sound private static void TryEmitSound(BaseEmitSoundComponent component) { - if (component.Sound.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(component.Owner), sound, component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); - } - else - { - Logger.Warning($"{nameof(component)} Uid:{component.Owner.Uid} has no {nameof(component.Sound)} to play."); - } + SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f)); } } } diff --git a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs index 5b943e5f77..9606dddcd9 100644 --- a/Content.Server/Storage/Components/CursedEntityStorageComponent.cs +++ b/Content.Server/Storage/Components/CursedEntityStorageComponent.cs @@ -17,7 +17,7 @@ namespace Content.Server.Storage.Components [RegisterComponent] public class CursedEntityStorageComponent : EntityStorageComponent { - [Dependency] private readonly IRobustRandom _robustRandom = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; public override string Name => "CursedEntityStorage"; @@ -42,7 +42,7 @@ namespace Content.Server.Storage.Components var locker = lockerEnt.GetComponent(); - if(locker.Open) + if (locker.Open) locker.TryCloseStorage(Owner); foreach (var entity in Contents.ContainedEntities.ToArray()) @@ -51,10 +51,8 @@ namespace Content.Server.Storage.Components locker.Insert(entity); } - if(_cursedSound.TryGetSound(out var cursedSound)) - 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)); + SoundSystem.Play(Filter.Pvs(Owner), _cursedSound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(lockerEnt), _cursedLockerSound.GetSound(), lockerEnt, AudioHelpers.WithVariation(0.125f)); } } } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index f8b63b6bbd..451d189d59 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -226,8 +226,7 @@ namespace Content.Server.Storage.Components } ModifyComponents(); - if(_closeSound.TryGetSound(out var closeSound)) - SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _closeSound.GetSound(), Owner); _lastInternalOpenAttempt = default; } @@ -236,8 +235,7 @@ namespace Content.Server.Storage.Components Open = true; EmptyContents(); ModifyComponents(); - if(_openSound.TryGetSound(out var openSound)) - SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _openSound.GetSound(), Owner); } private void UpdateAppearance() diff --git a/Content.Server/Storage/Components/ServerStorageComponent.cs b/Content.Server/Storage/Components/ServerStorageComponent.cs index f96da5ced6..86a4ff89f3 100644 --- a/Content.Server/Storage/Components/ServerStorageComponent.cs +++ b/Content.Server/Storage/Components/ServerStorageComponent.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using Content.Server.DoAfter; using Content.Server.Hands.Components; using Content.Server.Items; using Content.Server.Placeable; using Content.Shared.Acts; -using Content.Shared.Audio; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; using Content.Shared.Item; -using Content.Shared.Notification; using Content.Shared.Notification.Managers; using Content.Shared.Sound; using Content.Shared.Storage; @@ -31,6 +24,11 @@ using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace Content.Server.Storage.Components { @@ -66,7 +64,7 @@ namespace Content.Server.Storage.Components public readonly HashSet SubscribedSessions = new(); [DataField("storageSoundCollection")] - public SoundSpecifier StorageSoundCollection { get; set; } = default!; + public SoundSpecifier StorageSoundCollection { get; set; } = new SoundCollectionSpecifier("storageRustle"); [ViewVariables] public override IReadOnlyList? StoredEntities => _storage?.ContainedEntities; @@ -389,79 +387,79 @@ namespace Content.Server.Storage.Components switch (message) { case RemoveEntityMessage remove: - { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) + { + break; + } + + var ownerTransform = Owner.Transform; + var playerTransform = player.Transform; + + if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || + !ownerTransform.IsMapTransform && + !playerTransform.ContainsEntity(ownerTransform)) + { + break; + } + + var entity = Owner.EntityManager.GetEntity(remove.EntityUid); + + if (entity == null || _storage?.Contains(entity) == false) + { + break; + } + + var item = entity.GetComponent(); + if (item == null || + !player.TryGetComponent(out HandsComponent? hands)) + { + break; + } + + if (!hands.CanPutInHand(item)) + { + break; + } + + hands.PutInHand(item); + break; } - - var ownerTransform = Owner.Transform; - var playerTransform = player.Transform; - - if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) || - !ownerTransform.IsMapTransform && - !playerTransform.ContainsEntity(ownerTransform)) - { - break; - } - - var entity = Owner.EntityManager.GetEntity(remove.EntityUid); - - if (entity == null || _storage?.Contains(entity) == false) - { - break; - } - - var item = entity.GetComponent(); - if (item == null || - !player.TryGetComponent(out HandsComponent? hands)) - { - break; - } - - if (!hands.CanPutInHand(item)) - { - break; - } - - hands.PutInHand(item); - - break; - } case InsertEntityMessage _: - { - EnsureInitialCalculated(); - - var player = session.AttachedEntity; - - if (player == null) { + EnsureInitialCalculated(); + + var player = session.AttachedEntity; + + if (player == null) + { + break; + } + + if (!player.InRangeUnobstructed(Owner, popup: true)) + { + break; + } + + PlayerInsertHeldEntity(player); + break; } - - if (!player.InRangeUnobstructed(Owner, popup: true)) - { - break; - } - - PlayerInsertHeldEntity(player); - - break; - } case CloseStorageUIMessage _: - { - if (session is not IPlayerSession playerSession) { + if (session is not IPlayerSession playerSession) + { + break; + } + + UnsubscribeSession(playerSession); break; } - - UnsubscribeSession(playerSession); - break; - } } } @@ -511,7 +509,7 @@ namespace Content.Server.Storage.Components // Pick up all entities in a radius around the clicked location. // The last half of the if is because carpets exist and this is terrible - if(_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent())) + if (_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent())) { var validStorables = new List(); foreach (var entity in IoCManager.Resolve().GetEntitiesInRange(eventArgs.ClickLocation, 1)) @@ -556,7 +554,7 @@ namespace Content.Server.Storage.Components } // If we picked up atleast one thing, play a sound and do a cool animation! - if (successfullyInserted.Count>0) + if (successfullyInserted.Count > 0) { PlaySoundCollection(); SendNetworkMessage( @@ -569,7 +567,7 @@ namespace Content.Server.Storage.Components return true; } // Pick up the clicked entity - else if(_quickInsert) + else if (_quickInsert) { if (eventArgs.Target == null || !eventArgs.Target.Transform.IsMapTransform @@ -577,7 +575,7 @@ namespace Content.Server.Storage.Components || !eventArgs.Target.HasComponent()) return false; var position = eventArgs.Target.Transform.Coordinates; - if(PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target)) + if (PlayerInsertEntityInWorld(eventArgs.User, eventArgs.Target)) { SendNetworkMessage(new AnimateInsertingEntitiesMessage( new List() { eventArgs.Target.Uid }, @@ -631,9 +629,7 @@ namespace Content.Server.Storage.Components private void PlaySoundCollection() { - // TODO this doesn't compile or work - if(StorageSoundCollection?.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default); + SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default); } } } diff --git a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs index 0956e8a5f3..fcf203137d 100644 --- a/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs +++ b/Content.Server/Storage/Components/SpawnItemsOnUseComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Content.Shared.Sound; using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; @@ -23,7 +23,7 @@ namespace Content.Server.Storage.Components /// /// A sound to play when the items are spawned. For example, gift boxes being unwrapped. /// - [DataField("sound")] + [DataField("sound", required: true)] public SoundSpecifier? Sound = null; /// diff --git a/Content.Server/Stunnable/Components/StunnableComponent.cs b/Content.Server/Stunnable/Components/StunnableComponent.cs index b799f267bf..da72ca145b 100644 --- a/Content.Server/Stunnable/Components/StunnableComponent.cs +++ b/Content.Server/Stunnable/Components/StunnableComponent.cs @@ -29,7 +29,7 @@ namespace Content.Server.Stunnable.Components protected override void OnKnockdownEnd() { - if(Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) + if (Owner.TryGetComponent(out IMobStateComponent? mobState) && !mobState.IsIncapacitated()) EntitySystem.Get().Stand(Owner); } @@ -57,8 +57,7 @@ namespace Content.Server.Stunnable.Components protected override void OnInteractHand() { - if(_stunAttemptSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play(Filter.Pvs(Owner), _stunAttemptSound.GetSound(), Owner, AudioHelpers.WithVariation(0.05f)); } bool IDisarmedAct.Disarmed(DisarmedActEventArgs eventArgs) @@ -73,12 +72,11 @@ namespace Content.Server.Stunnable.Components if (source != null) { - if (_stunAttemptSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(source), sound, source, AudioHelpers.WithVariation(0.025f)); + SoundSystem.Play(Filter.Pvs(source), _stunAttemptSound.GetSound(), source, AudioHelpers.WithVariation(0.025f)); if (target != null) { - source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name),("target", target.Name))); - source.PopupMessageCursor(Loc.GetString("stunnable-component-disarm-success",("target", target.Name))); + source.PopupMessageOtherClients(Loc.GetString("stunnable-component-disarm-success-others", ("source", source.Name), ("target", target.Name))); + source.PopupMessageCursor(Loc.GetString("stunnable-component-disarm-success", ("target", target.Name))); } } diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index fc705d77a0..61f690b31b 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -119,18 +119,17 @@ namespace Content.Server.Stunnable { if (!entity.TryGetComponent(out StunnableComponent? stunnable) || !comp.Activated) return; - 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) + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.StunSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + if (!stunnable.SlowedDown) { - if(_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) + if (_robustRandom.Prob(comp.ParalyzeChanceNoSlowdown)) stunnable.Paralyze(comp.ParalyzeTime); else stunnable.Slowdown(comp.SlowdownTime); } else { - if(_robustRandom.Prob(comp.ParalyzeChanceWithSlowdown)) + if (_robustRandom.Prob(comp.ParalyzeChanceWithSlowdown)) stunnable.Paralyze(comp.ParalyzeTime); else stunnable.Slowdown(comp.SlowdownTime); @@ -140,8 +139,7 @@ namespace Content.Server.Stunnable if (!comp.Owner.TryGetComponent(out var slot) || slot.Cell == null || !(slot.Cell.CurrentCharge < comp.EnergyPerUse)) return; - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); TurnOff(comp); } @@ -155,8 +153,7 @@ namespace Content.Server.Stunnable if (!comp.Owner.TryGetComponent(out var sprite) || !comp.Owner.TryGetComponent(out var item)) return; - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(Filter.Pvs(comp.Owner), sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(comp.Owner), comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "off"; // TODO stunbaton visualizer sprite.LayerSetState(0, "stunbaton_off"); @@ -180,22 +177,19 @@ namespace Content.Server.Stunnable if (slot.Cell == null) { - if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.TurnOnFailSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-missing-cell")); return; } if (slot.Cell != null && slot.Cell.CurrentCharge < comp.EnergyPerUse) { - if(comp.TurnOnFailSound.TryGetSound(out var turnOnFailSound)) - SoundSystem.Play(playerFilter, turnOnFailSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.TurnOnFailSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); user.PopupMessage(Loc.GetString("comp-stunbaton-activated-dead-cell")); return; } - if(comp.SparksSound.TryGetSound(out var sparksSound)) - SoundSystem.Play(playerFilter, sparksSound, comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(playerFilter, comp.SparksSound.GetSound(), comp.Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.25f)); item.EquippedPrefix = "on"; sprite.LayerSetState(0, "stunbaton_on"); diff --git a/Content.Server/Tiles/FloorTileItemComponent.cs b/Content.Server/Tiles/FloorTileItemComponent.cs index 6399fadc63..4cb9b5de34 100644 --- a/Content.Server/Tiles/FloorTileItemComponent.cs +++ b/Content.Server/Tiles/FloorTileItemComponent.cs @@ -23,7 +23,7 @@ namespace Content.Server.Tiles [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; public override string Name => "FloorTile"; - [DataField("outputs", customTypeSerializer:typeof(PrototypeIdListSerializer))] + [DataField("outputs", customTypeSerializer: typeof(PrototypeIdListSerializer))] private List? _outputTiles; [DataField("placeTileSound")] SoundSpecifier _placeTileSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg"); @@ -50,8 +50,7 @@ namespace Content.Server.Tiles private void PlaceAt(IMapGrid mapGrid, EntityCoordinates location, ushort tileId, float offset = 0) { mapGrid.SetTile(location.Offset(new Vector2(offset, offset)), new Tile(tileId)); - if(_placeTileSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(location), sound, location, AudioHelpers.WithVariation(0.125f)); + SoundSystem.Play(Filter.Pvs(location), _placeTileSound.GetSound(), location, AudioHelpers.WithVariation(0.125f)); } async Task IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs) diff --git a/Content.Server/Toilet/ToiletComponent.cs b/Content.Server/Toilet/ToiletComponent.cs index 2d9e3a069c..f010ced8e9 100644 --- a/Content.Server/Toilet/ToiletComponent.cs +++ b/Content.Server/Toilet/ToiletComponent.cs @@ -130,8 +130,7 @@ namespace Content.Server.Toilet public void ToggleToiletSeat() { IsSeatUp = !IsSeatUp; - if(_toggleSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play(Filter.Pvs(Owner), _toggleSound.GetSound(), Owner, AudioHelpers.WithVariation(0.05f)); UpdateSprite(); } diff --git a/Content.Server/Tools/Components/MultitoolComponent.cs b/Content.Server/Tools/Components/MultitoolComponent.cs index 1fedb20e80..ecc6289ff4 100644 --- a/Content.Server/Tools/Components/MultitoolComponent.cs +++ b/Content.Server/Tools/Components/MultitoolComponent.cs @@ -33,10 +33,10 @@ namespace Content.Server.Tools.Components [DataField("sprite")] public string Sprite { get; } = string.Empty; - [DataField("useSound")] + [DataField("useSound", required: true)] public SoundSpecifier Sound { get; } = default!; - [DataField("changeSound")] + [DataField("changeSound", required: true)] public SoundSpecifier ChangeSound { get; } = default!; } @@ -60,8 +60,7 @@ namespace Content.Server.Tools.Components _currentTool = (_currentTool + 1) % _tools.Count; SetTool(); var current = _tools[_currentTool]; - if(current.ChangeSound.TryGetSound(out var changeSound)) - SoundSystem.Play(Filter.Pvs(Owner), changeSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), current.ChangeSound.GetSound(), Owner); } private void SetTool() diff --git a/Content.Server/Tools/Components/ToolComponent.cs b/Content.Server/Tools/Components/ToolComponent.cs index 9213c1877c..be65dd3ff4 100644 --- a/Content.Server/Tools/Components/ToolComponent.cs +++ b/Content.Server/Tools/Components/ToolComponent.cs @@ -44,7 +44,7 @@ namespace Content.Server.Tools.Components [DataField("speed")] public float SpeedModifier { get; set; } = 1; - [DataField("useSound")] + [DataField("useSound", required: true)] public SoundSpecifier UseSound { get; set; } = default!; public void AddQuality(ToolQuality quality) @@ -96,8 +96,7 @@ namespace Content.Server.Tools.Components public void PlayUseSound(float volume = -5f) { - if(UseSound.TryGetSound(out var useSound)) - SoundSystem.Play(Filter.Pvs(Owner), useSound, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + SoundSystem.Play(Filter.Pvs(Owner), UseSound.GetSound(), Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); } } } diff --git a/Content.Server/Tools/Components/WelderComponent.cs b/Content.Server/Tools/Components/WelderComponent.cs index ad8cc9cc0f..2faf2a0d96 100644 --- a/Content.Server/Tools/Components/WelderComponent.cs +++ b/Content.Server/Tools/Components/WelderComponent.cs @@ -60,7 +60,7 @@ namespace Content.Server.Tools.Components private SolutionContainerComponent? _solutionComponent; private PointLightComponent? _pointLightComponent; - [DataField("weldSounds")] + [DataField("weldSounds", required: true)] private SoundSpecifier WeldSounds { get; set; } = default!; [DataField("welderOffSounds")] @@ -171,9 +171,9 @@ namespace Content.Server.Tools.Components var succeeded = _solutionComponent.TryRemoveReagent("WeldingFuel", ReagentUnit.New(value)); - if (succeeded && !silent && WeldSounds.TryGetSound(out var weldSounds)) + if (succeeded && !silent) { - PlaySound(weldSounds); + PlaySound(WeldSounds); } return succeeded; } @@ -204,8 +204,7 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = false; - if(WelderOffSounds.TryGetSound(out var welderOffSOunds)) - PlaySound(welderOffSOunds, -5); + PlaySound(WelderOffSounds, -5); _welderSystem.Unsubscribe(this); return true; } @@ -222,8 +221,7 @@ namespace Content.Server.Tools.Components if (_pointLightComponent != null) _pointLightComponent.Enabled = true; - if (WelderOnSounds.TryGetSound(out var welderOnSOunds)) - PlaySound(welderOnSOunds, -5); + PlaySound(WelderOnSounds, -5); _welderSystem.Subscribe(this); EntitySystem.Get().HotspotExpose(Owner.Transform.Coordinates, 700, 50, true); @@ -283,8 +281,7 @@ namespace Content.Server.Tools.Components if (TryWeld(5, victim, silent: true)) { - if(WeldSounds.TryGetSound(out var weldSound)) - PlaySound(weldSound); + PlaySound(WeldSounds); othersMessage = Loc.GetString("welder-component-suicide-lit-others-message", @@ -337,8 +334,7 @@ namespace Content.Server.Tools.Components { var drained = targetSolution.Drain(trans); _solutionComponent.TryAddSolution(drained); - if(WelderRefill.TryGetSound(out var welderRefillSound)) - SoundSystem.Play(Filter.Pvs(Owner), welderRefillSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), WelderRefill.GetSound(), Owner); eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("welder-component-after-interact-refueled-message")); } } @@ -346,9 +342,9 @@ namespace Content.Server.Tools.Components return true; } - private void PlaySound(string soundName, float volume = -5f) + private void PlaySound(SoundSpecifier sound, float volume = -5f) { - SoundSystem.Play(Filter.Pvs(Owner), soundName, Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); + SoundSystem.Play(Filter.Pvs(Owner), sound.GetSound(), Owner, AudioHelpers.WithVariation(0.15f).WithVolume(volume)); } } } diff --git a/Content.Server/VendingMachines/VendingMachineComponent.cs b/Content.Server/VendingMachines/VendingMachineComponent.cs index 6914978eb7..d021cc5018 100644 --- a/Content.Server/VendingMachines/VendingMachineComponent.cs +++ b/Content.Server/VendingMachines/VendingMachineComponent.cs @@ -202,8 +202,7 @@ namespace Content.Server.VendingMachines Owner.EntityManager.SpawnEntity(id, Owner.Transform.Coordinates); }); - if(_soundVend.TryGetSound(out var soundVend)) - SoundSystem.Play(Filter.Pvs(Owner), soundVend, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _soundVend.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); } private void TryEject(string id, IEntity? sender) @@ -222,8 +221,7 @@ namespace Content.Server.VendingMachines private void Deny() { - if(_soundDeny.TryGetSound(out var soundDeny)) - SoundSystem.Play(Filter.Pvs(Owner), soundDeny, Owner, AudioParams.Default.WithVolume(-2f)); + SoundSystem.Play(Filter.Pvs(Owner), _soundDeny.GetSound(), Owner, AudioParams.Default.WithVolume(-2f)); // Play the Deny animation TrySetVisualState(VendingMachineVisualState.Deny); diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index a4de423800..73b26b878a 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -78,12 +78,12 @@ namespace Content.Server.Weapon.Melee if (target != null) { // Raise event before doing damage so we can cancel damage if the event is handled - var hitEvent = new MeleeHitEvent(new List() {target}, args.User); + var hitEvent = new MeleeHitEvent(new List() { target }, args.User); RaiseLocalEvent(uid, hitEvent, false); if (!hitEvent.Handled) { - var targets = new[] {target}; + var targets = new[] { target }; SendAnimation(comp.ClickArc, angle, args.User, owner, targets, comp.ClickAttackEffect, false); if (target.TryGetComponent(out IDamageableComponent? damageableComponent)) @@ -91,14 +91,12 @@ namespace Content.Server.Weapon.Melee damageableComponent.ChangeDamage(comp.DamageType, comp.Damage, false, owner); } - if(comp.HitSound.TryGetSound(out var hitSound)) - SoundSystem.Play(Filter.Pvs(owner), hitSound, target); + SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), target); } } else { - if(comp.MissSound.TryGetSound(out var missSound)) - SoundSystem.Play(Filter.Pvs(owner), missSound, args.User); + SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), args.User); return; } @@ -148,13 +146,11 @@ namespace Content.Server.Weapon.Melee { if (entities.Count != 0) { - if(comp.HitSound.TryGetSound(out var hitSound)) - SoundSystem.Play(Filter.Pvs(owner), hitSound, entities.First().Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), entities.First().Transform.Coordinates); } else { - if(comp.MissSound.TryGetSound(out var missSound)) - SoundSystem.Play(Filter.Pvs(owner), missSound, args.User.Transform.Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), args.User.Transform.Coordinates); } foreach (var entity in hitEntities) diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs index 34369505b7..cd0c089371 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/BoltActionBarrelComponent.cs @@ -75,18 +75,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } else { TryFeedChamber(); - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _boltOpen = value; @@ -102,7 +96,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Sounds [DataField("soundCycle")] - private SoundSpecifier _soundCycle = new SoundPathSpecifier( "/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); + private SoundSpecifier _soundCycle = new SoundPathSpecifier("/Audio/Weapons/Guns/Cock/sf_rifle_cock.ogg"); [DataField("soundBoltOpen")] private SoundSpecifier _soundBoltOpen = new SoundPathSpecifier("/Audio/Weapons/Guns/Bolt/rifle_bolt_open.ogg"); [DataField("soundBoltClosed")] @@ -225,10 +219,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } else { - if (_soundCycle.TryGetSound(out var soundCycle)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundCycle, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundCycle.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -257,10 +248,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null) { _chamberContainer.Insert(ammo); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); return true; @@ -270,10 +258,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { _ammoContainer.Insert(ammo); _spawnedAmmo.Push(ammo); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); return true; @@ -347,7 +332,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("bolt-action-barrel-component-on-examine", ("caliber",_caliber))); + message.AddMarkup("\n" + Loc.GetString("bolt-action-barrel-component-on-examine", ("caliber", _caliber))); } [Verb] diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs index 348db086db..41e12042d4 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/PumpBarrelComponent.cs @@ -46,7 +46,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components // Even a point having a chamber? I guess it makes some of the below code cleaner private ContainerSlot _chamberContainer = default!; - private Stack _spawnedAmmo = new (DefaultCapacity-1); + private Stack _spawnedAmmo = new(DefaultCapacity - 1); private Container _ammoContainer = default!; [ViewVariables] @@ -190,10 +190,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (_soundCycle.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundCycle.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -219,10 +216,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _spawnedAmmo.Push(eventArgs.Using); Dirty(); UpdateAppearance(); - if (_soundInsert.TryGetSound(out var soundInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); return true; } @@ -246,7 +240,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("pump-barrel-component-on-examine",("caliber", _caliber))); + message.AddMarkup("\n" + Loc.GetString("pump-barrel-component-on-examine", ("caliber", _caliber))); } } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs index ed38699ee1..d02f8d6f97 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/RevolverBarrelComponent.cs @@ -165,10 +165,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components _currentSlot = i; _ammoSlots[i] = entity; _ammoContainer.Insert(entity); - if (_soundInsert.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); UpdateAppearance(); @@ -195,10 +192,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { var random = _random.Next(_ammoSlots.Length - 1); _currentSlot = random; - if (_soundSpin.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundSpin.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Dirty(); } @@ -249,10 +243,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_ammoContainer.ContainedEntities.Count > 0) { - if (_soundEject.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } // May as well point back at the end? diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs index 5104100622..1b17844992 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerBatteryBarrelComponent.cs @@ -83,9 +83,9 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components private AppearanceComponent? _appearanceComponent; // Sounds - [DataField("soundPowerCellInsert")] + [DataField("soundPowerCellInsert", required: true)] private SoundSpecifier _soundPowerCellInsert = default!; - [DataField("soundPowerCellEject")] + [DataField("soundPowerCellEject", required: true)] private SoundSpecifier _soundPowerCellEject = default!; public override ComponentState GetComponentState(ICommonSession player) @@ -223,10 +223,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components return false; } - if (_soundPowerCellInsert.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); _powerCellContainer.Insert(entity); @@ -276,10 +273,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components cell.Owner.Transform.Coordinates = user.Transform.Coordinates; } - if (_soundPowerCellEject.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundPowerCellEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); return true; } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs index 429c5d5b65..fbc6d4fed7 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerMagazineBarrelComponent.cs @@ -98,18 +98,12 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (value) { TryEjectChamber(); - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } else { TryFeedChamber(); - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } _boltOpen = value; @@ -129,17 +123,17 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components private AppearanceComponent? _appearanceComponent; // Sounds - [DataField("soundBoltOpen")] + [DataField("soundBoltOpen", required: true)] private SoundSpecifier _soundBoltOpen = default!; - [DataField("soundBoltClosed")] + [DataField("soundBoltClosed", required: true)] private SoundSpecifier _soundBoltClosed = default!; - [DataField("soundRack")] + [DataField("soundRack", required: true)] private SoundSpecifier _soundRack = default!; - [DataField("soundMagInsert")] + [DataField("soundMagInsert", required: true)] private SoundSpecifier _soundMagInsert = default!; - [DataField("soundMagEject")] + [DataField("soundMagEject", required: true)] private SoundSpecifier _soundMagEject = default!; - [DataField("soundAutoEject")] + [DataField("soundAutoEject", required: true)] private SoundSpecifier _soundAutoEject = new SoundPathSpecifier("/Audio/Weapons/Guns/EmptyAlarm/smg_empty_alarm.ogg"); private List GetMagazineTypes() @@ -229,10 +223,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_chamberContainer.ContainedEntity == null && !BoltOpen) { - if (_soundBoltOpen.TryGetSound(out var soundBoltOpen)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltOpen, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltOpen.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); if (Owner.TryGetContainer(out var container)) { @@ -244,10 +235,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (manual) { - if (_soundRack.TryGetSound(out var soundRack)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundRack, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundRack.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); } Dirty(); @@ -272,10 +260,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (BoltOpen) { - if (_soundBoltClosed.TryGetSound(out var soundBoltClosed)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundBoltClosed, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundBoltClosed.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-5)); Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-use-entity-bolt-closed")); BoltOpen = false; return true; @@ -326,10 +311,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_autoEjectMag && magazine != null && magazine.GetComponent().ShotsLeft == 0) { - if (_soundAutoEject.TryGetSound(out var soundAutoEject)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundAutoEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundAutoEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); _magazineContainer.Remove(magazine); SendNetworkMessage(new MagazineAutoEjectMessage()); @@ -353,10 +335,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components } _magazineContainer.Remove(mag); - if (_soundMagEject.TryGetSound(out var soundMagEject)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundMagEject, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundMagEject.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); if (user.TryGetComponent(out HandsComponent? handsComponent)) { @@ -392,10 +371,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components if (_magazineContainer.ContainedEntity == null) { - if (_soundMagInsert.TryGetSound(out var soundMagInsert)) - { - SoundSystem.Play(Filter.Pvs(Owner), soundMagInsert, Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); - } + SoundSystem.Play(Filter.Pvs(Owner), _soundMagInsert.GetSound(), Owner.Transform.Coordinates, AudioParams.Default.WithVolume(-2)); Owner.PopupMessage(eventArgs.User, Loc.GetString("server-magazine-barrel-component-interact-using-success")); _magazineContainer.Insert(eventArgs.Using); Dirty(); @@ -442,11 +418,11 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { base.Examine(message, inDetailsRange); - message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine", ("caliber",Caliber))); + message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine", ("caliber", Caliber))); foreach (var magazineType in GetMagazineTypes()) { - message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine-magazine-type",("magazineType", magazineType))); + message.AddMarkup("\n" + Loc.GetString("server-magazine-barrel-component-on-examine-magazine-type", ("magazineType", magazineType))); } } diff --git a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs index 4ab245d7d9..0a588126b6 100644 --- a/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs +++ b/Content.Server/Weapon/Ranged/Barrels/Components/ServerRangedBarrelComponent.cs @@ -97,7 +97,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components public bool CanMuzzleFlash { get; } = true; // Sounds - [DataField("soundGunshot")] + [DataField("soundGunshot", required: true)] public SoundSpecifier SoundGunshot { get; set; } = default!; [DataField("soundEmpty")] @@ -197,10 +197,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components { if (ShotsLeft == 0) { - if (SoundEmpty.TryGetSound(out var sound)) - { - SoundSystem.Play(Filter.Broadcast(), sound, Owner.Transform.Coordinates); - } + SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner.Transform.Coordinates); return; } @@ -208,8 +205,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components var projectile = TakeProjectile(shooter.Transform.Coordinates); if (projectile == null) { - if(SoundEmpty.TryGetSound(out var soundEmpty)) - SoundSystem.Play(Filter.Broadcast(), soundEmpty, Owner.Transform.Coordinates); + SoundSystem.Play(Filter.Broadcast(), SoundEmpty.GetSound(), Owner.Transform.Coordinates); return; } @@ -249,10 +245,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components throw new InvalidOperationException(); } - if (SoundGunshot.TryGetSound(out var soundGunshot)) - { - SoundSystem.Play(Filter.Broadcast(), soundGunshot, Owner.Transform.Coordinates); - } + SoundSystem.Play(Filter.Broadcast(), SoundGunshot.GetSound(), Owner.Transform.Coordinates); _lastFire = _gameTiming.CurTime; } @@ -283,10 +276,7 @@ namespace Content.Server.Weapon.Ranged.Barrels.Components entity.Transform.Coordinates = entity.Transform.Coordinates.Offset(offsetPos); entity.Transform.LocalRotation = robustRandom.Pick(ejectDirections).ToAngle(); - if (ammo.SoundCollectionEject.TryGetSound(out var ejectSounds) && playSound) - { - SoundSystem.Play(Filter.Broadcast(), ejectSounds, entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); - } + SoundSystem.Play(Filter.Broadcast(), ammo.SoundCollectionEject.GetSound(), entity.Transform.Coordinates, AudioParams.Default.WithVolume(-1)); } /// diff --git a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs index 345a69e33e..8a6fdeaccf 100644 --- a/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs +++ b/Content.Server/Weapon/Ranged/ServerRangedWeaponComponent.cs @@ -147,7 +147,8 @@ namespace Content.Server.Weapon.Ranged return; } - if(!user.TryGetComponent(out CombatModeComponent? combat) || !combat.IsInCombatMode) { + if (!user.TryGetComponent(out CombatModeComponent? combat) || !combat.IsInCombatMode) + { return; } @@ -167,13 +168,13 @@ namespace Content.Server.Weapon.Ranged if (ClumsyCheck && ClumsyComponent.TryRollClumsy(user, ClumsyExplodeChance)) { - if(_clumsyWeaponHandlingSound.TryGetSound(out var clumsyWeaponHandlingSound)) - SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponHandlingSound, - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + SoundSystem.Play( + Filter.Pvs(Owner), _clumsyWeaponHandlingSound.GetSound(), + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); - if(_clumsyWeaponShotSound.TryGetSound(out var clumsyWeaponShotSound)) - SoundSystem.Play(Filter.Pvs(Owner), clumsyWeaponShotSound, - Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); + SoundSystem.Play( + Filter.Pvs(Owner), _clumsyWeaponShotSound.GetSound(), + Owner.Transform.Coordinates, AudioParams.Default.WithMaxDistance(5)); if (user.TryGetComponent(out IDamageableComponent? health)) { diff --git a/Content.Server/Window/WindowComponent.cs b/Content.Server/Window/WindowComponent.cs index b9d38a3f3a..fb83630d11 100644 --- a/Content.Server/Window/WindowComponent.cs +++ b/Content.Server/Window/WindowComponent.cs @@ -31,7 +31,8 @@ namespace Content.Server.Window [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _lastKnockTime; - [DataField("knockDelay")] [ViewVariables(VVAccess.ReadWrite)] + [DataField("knockDelay")] + [ViewVariables(VVAccess.ReadWrite)] private TimeSpan _knockDelay = TimeSpan.FromSeconds(0.5); [DataField("rateLimitedKnocking")] @@ -47,11 +48,11 @@ namespace Content.Server.Window switch (message) { case DamageChangedMessage msg: - { - var current = msg.Damageable.TotalDamage; - UpdateVisuals(current); - break; - } + { + var current = msg.Damageable.TotalDamage; + UpdateVisuals(current); + break; + } } } @@ -133,9 +134,9 @@ namespace Content.Server.Window return false; } - if(_knockSound.TryGetSound(out var sound)) - SoundSystem.Play(Filter.Pvs(eventArgs.Target), sound, - eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); + SoundSystem.Play( + Filter.Pvs(eventArgs.Target), _knockSound.GetSound(), + eventArgs.Target.Transform.Coordinates, AudioHelpers.WithVariation(0.05f)); eventArgs.Target.PopupMessageEveryone(Loc.GetString("comp-window-knock")); _lastKnockTime = _gameTiming.CurTime; diff --git a/Content.Server/WireHacking/WiresComponent.cs b/Content.Server/WireHacking/WiresComponent.cs index c6d16b8d58..ffa9def798 100644 --- a/Content.Server/WireHacking/WiresComponent.cs +++ b/Content.Server/WireHacking/WiresComponent.cs @@ -456,8 +456,7 @@ namespace Content.Server.WireHacking return; } - if(_pulseSound.TryGetSound(out var pulseSound)) - SoundSystem.Play(Filter.Pvs(Owner), pulseSound, Owner); + SoundSystem.Play(Filter.Pvs(Owner), _pulseSound.GetSound(), Owner); break; } @@ -509,17 +508,11 @@ namespace Content.Server.WireHacking IsPanelOpen = !IsPanelOpen; if (IsPanelOpen) { - if(_screwdriverOpenSound.TryGetSound(out var openSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), openSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _screwdriverOpenSound.GetSound(), Owner); } else { - if (_screwdriverCloseSound.TryGetSound(out var closeSound)) - { - SoundSystem.Play(Filter.Pvs(Owner), closeSound, Owner); - } + SoundSystem.Play(Filter.Pvs(Owner), _screwdriverCloseSound.GetSound(), Owner); } return true; diff --git a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs index 1ee1cd35c9..000cb5a37b 100644 --- a/Content.Shared/Light/Component/SharedExpendableLightComponent.cs +++ b/Content.Shared/Light/Component/SharedExpendableLightComponent.cs @@ -69,11 +69,11 @@ namespace Content.Shared.Light.Component protected string IconStateLit { get; set; } = string.Empty; [ViewVariables] - [DataField("litSound")] + [DataField("litSound", required: true)] protected SoundSpecifier LitSound { get; set; } = default!; [ViewVariables] - [DataField("loopedSound")] + [DataField("loopedSound", required: true)] public string LoopedSound { get; set; } = string.Empty; [ViewVariables] diff --git a/Content.Shared/Maps/ContentTileDefinition.cs b/Content.Shared/Maps/ContentTileDefinition.cs index cc7f5961e0..6f82ad0768 100644 --- a/Content.Shared/Maps/ContentTileDefinition.cs +++ b/Content.Shared/Maps/ContentTileDefinition.cs @@ -32,7 +32,7 @@ namespace Content.Shared.Maps [DataField("can_crowbar")] public bool CanCrowbar { get; private set; } - [DataField("footstep_sounds")] public SoundSpecifier FootstepSounds { get; } = default!; + [DataField("footstep_sounds", required: true)] public SoundSpecifier FootstepSounds { get; } = default!; [DataField("friction")] public float Friction { get; set; } diff --git a/Content.Shared/Sound/SoundSpecifier.cs b/Content.Shared/Sound/SoundSpecifier.cs index a911c5db81..35b38e823d 100644 --- a/Content.Shared/Sound/SoundSpecifier.cs +++ b/Content.Shared/Sound/SoundSpecifier.cs @@ -3,7 +3,6 @@ using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Utility; -using System.Diagnostics.CodeAnalysis; namespace Content.Shared.Sound { @@ -11,8 +10,6 @@ namespace Content.Shared.Sound public abstract class SoundSpecifier { public abstract string GetSound(); - - public abstract bool TryGetSound([NotNullWhen(true)] out string? sound); } public sealed class SoundPathSpecifier : SoundSpecifier @@ -40,12 +37,6 @@ namespace Content.Shared.Sound { return Path == null ? string.Empty : Path.ToString(); } - - public override bool TryGetSound([NotNullWhen(true)] out string? sound) - { - sound = GetSound(); - return !string.IsNullOrWhiteSpace(sound); - } } public sealed class SoundCollectionSpecifier : SoundSpecifier @@ -68,11 +59,5 @@ namespace Content.Shared.Sound { return Collection == null ? string.Empty : AudioHelpers.GetRandomFileFromSoundCollection(Collection); } - - public override bool TryGetSound([NotNullWhen(true)] out string? sound) - { - sound = GetSound(); - return !string.IsNullOrWhiteSpace(sound); - } } } diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 7f96cc3bf8..6898ca2c02 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -61,9 +61,9 @@ namespace Content.Shared.Standing } // Currently shit is only downed by server but when it's predicted we can probably only play this on server / client - if (playSound && component.DownSoundCollection.TryGetSound(out var sound)) + if (playSound) { - SoundSystem.Play(Filter.Pvs(entity), sound, entity, AudioHelpers.WithVariation(0.25f)); + SoundSystem.Play(Filter.Pvs(entity), component.DownSoundCollection.GetSound(), entity, AudioHelpers.WithVariation(0.25f)); } }