Merge pull request #4401 from GalacticChimp/replace-sounds-with-sound-specifier

Replace sounds with SoundSpecifier
This commit is contained in:
ShadowCommander
2021-08-10 18:51:11 -07:00
committed by GitHub
216 changed files with 1484 additions and 1121 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
@@ -39,7 +40,7 @@ namespace Content.Client.Disposal.Visualizers
private string? _stateFlush;
[DataField("flush_sound", required: true)]
private string? _flushSound;
private SoundSpecifier _flushSound = default!;
[DataField("flush_time", required: true)]
private float _flushTime;
@@ -58,10 +59,7 @@ namespace Content.Client.Disposal.Visualizers
var sound = new AnimationTrackPlaySound();
_flushAnimation.AnimationTracks.Add(sound);
if (_flushSound != null)
{
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound, 0));
}
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(_flushSound.GetSound(), 0));
}
private void ChangeState(AppearanceComponent appearance)

View File

@@ -1,8 +1,8 @@
using System;
using Content.Client.Wires;
using Content.Client.Wires.Visualizers;
using Content.Shared.Audio;
using Content.Shared.Doors;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;

View File

@@ -1,5 +1,6 @@
using System;
using Content.Shared.Light;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
@@ -17,7 +18,7 @@ namespace Content.Client.Light.Visualizers
{
[DataField("minBlinkingTime")] private float _minBlinkingTime = 0.5f;
[DataField("maxBlinkingTime")] private float _maxBlinkingTime = 2;
[DataField("blinkingSound")] private string? _blinkingSound;
[DataField("blinkingSound", required: true)] private SoundSpecifier _blinkingSound = default!;
private bool _wasBlinking;
@@ -96,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 =
@@ -122,18 +123,15 @@ namespace Content.Client.Light.Visualizers
}
}
}
};
};
if (_blinkingSound != null)
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;
}

View File

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

View File

@@ -1,4 +1,5 @@
using System;
using System;
using Content.Shared.Sound;
using Content.Shared.Trigger;
using JetBrains.Annotations;
using Robust.Client.Animations;
@@ -14,8 +15,8 @@ namespace Content.Client.Trigger
{
private const string AnimationKey = "priming_animation";
[DataField("countdown_sound", required: true)]
private string? _countdownSound;
[DataField("countdown_sound")]
private SoundSpecifier _countdownSound = default!;
private Animation PrimingAnimation = default!;
@@ -28,12 +29,9 @@ namespace Content.Client.Trigger
flick.LayerKey = TriggerVisualLayers.Base;
flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("primed", 0f));
if (_countdownSound != null)
{
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));
}
}

View File

@@ -1,4 +1,4 @@
namespace Content.IntegrationTests.Tests.Destructible
namespace Content.IntegrationTests.Tests.Destructible
{
public static class DestructibleTestPrototypes
{
@@ -30,7 +30,8 @@
triggersOnce: false
behaviors:
- !type:PlaySoundBehavior
sound: /Audio/Effects/woodhit.ogg
sound:
path: /Audio/Effects/woodhit.ogg
- !type:SpawnEntitiesBehavior
spawn:
{SpawnedEntityId}:
@@ -52,7 +53,8 @@
damage: 50
behaviors:
- !type:PlaySoundBehavior
sound: /Audio/Effects/woodhit.ogg
sound:
path: /Audio/Effects/woodhit.ogg
- !type:SpawnEntitiesBehavior
spawn:
{SpawnedEntityId}:

View File

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

View File

@@ -10,12 +10,14 @@ using Content.Shared.AME;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.AME.Components
@@ -31,6 +33,8 @@ namespace Content.Server.AME.Components
private AppearanceComponent? _appearance;
private PowerSupplierComponent? _powerSupplier;
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("injectSound")] private SoundSpecifier _injectSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg");
private bool Powered => !Owner.TryGetComponent(out ApcPowerReceiverComponent? receiver) || receiver.Powered;
@@ -71,7 +75,7 @@ namespace Content.Server.AME.Components
internal void OnUpdate(float frameTime)
{
if(!_injecting)
if (!_injecting)
{
return;
}
@@ -84,11 +88,11 @@ namespace Content.Server.AME.Components
}
var jar = _jarSlot.ContainedEntity;
if(jar is null)
if (jar is null)
return;
jar.TryGetComponent<AMEFuelContainerComponent>(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);
@@ -101,7 +105,7 @@ namespace Content.Server.AME.Components
UpdateDisplay(_stability);
if(_stability <= 0) { group.ExplodeCores(); }
if (_stability <= 0) { group.ExplodeCores(); }
}
@@ -225,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);
@@ -258,7 +262,7 @@ namespace Content.Server.AME.Components
private void UpdateDisplay(int stability)
{
if(_appearance == null) { return; }
if (_appearance == null) { return; }
_appearance.TryGetData<string>(AMEControllerVisuals.DisplayState, out var state);
@@ -287,7 +291,7 @@ namespace Content.Server.AME.Components
private bool IsMasterController()
{
if(GetAMENodeGroup()?.MasterController == this)
if (GetAMENodeGroup()?.MasterController == this)
{
return true;
}
@@ -311,12 +315,12 @@ namespace Content.Server.AME.Components
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
private void InjectSound(bool overloading)
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
SoundSystem.Play(Filter.Pvs(Owner), _injectSound.GetSound(), Owner, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
}
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs args)

View File

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

View File

@@ -1,5 +1,3 @@
using System;
using System.Linq;
using Content.Server.Act;
using Content.Server.Interaction;
using Content.Server.Notification;
@@ -10,9 +8,9 @@ using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components;
using Content.Shared.Audio;
using Content.Shared.Cooldown;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -23,6 +21,9 @@ using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using System;
using System.Linq;
namespace Content.Server.Actions.Actions
{
@@ -34,6 +35,14 @@ namespace Content.Server.Actions.Actions
[DataField("pushProb")] private float _pushProb = 0.4f;
[DataField("cooldown")] private float _cooldown = 1.5f;
[ViewVariables]
[DataField("punchMissSound")]
private SoundSpecifier PunchMissSound { get; } = new SoundPathSpecifier("/Audio/Weapons/punchmiss.ogg");
[ViewVariables]
[DataField("disarmSuccessSound")]
private SoundSpecifier DisarmSuccessSound { get; } = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
public void DoTargetEntityAction(TargetEntityActionEventArgs args)
{
var disarmedActs = args.Target.GetAllComponents<IDisarmedAct>().ToArray();
@@ -69,8 +78,8 @@ namespace Content.Server.Actions.Actions
if (random.Prob(_failProb))
{
SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Weapons/punchmiss.ogg", 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),
("targetName", args.Target.Name)));
@@ -80,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));
@@ -93,8 +102,7 @@ namespace Content.Server.Actions.Actions
return;
}
SoundSystem.Play(Filter.Pvs(args.Performer), "/Audio/Effects/thudswoosh.ogg", args.Performer.Transform.Coordinates,
AudioHelpers.WithVariation(0.025f));
SoundSystem.Play(Filter.Pvs(args.Performer), DisarmSuccessSound.GetSound(), args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f));
}
}
}

View File

@@ -1,5 +1,3 @@
using System;
using System.Collections.Generic;
using Content.Server.CharacterAppearance.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.Actions.Behaviors;
@@ -7,7 +5,7 @@ using Content.Shared.Actions.Components;
using Content.Shared.Audio;
using Content.Shared.CharacterAppearance;
using Content.Shared.Cooldown;
using Content.Shared.Speech;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -15,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using System;
namespace Content.Server.Actions.Actions
{
@@ -27,9 +26,9 @@ namespace Content.Server.Actions.Actions
[Dependency] private readonly IRobustRandom _random = default!;
[DataField("male")] private List<string>? _male;
[DataField("female")] private List<string>? _female;
[DataField("wilhelm")] private string? _wilhelm;
[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;
@@ -45,31 +44,25 @@ namespace Content.Server.Actions.Actions
if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return;
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
if (_random.Prob(.01f) && !string.IsNullOrWhiteSpace(_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 == null) break;
SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_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 == null) break;
SoundSystem.Play(Filter.Pvs(args.Performer), _random.Pick(_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();
}
}
actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown));
}
}

View File

@@ -6,6 +6,7 @@ using Content.Shared.Actions.Behaviors;
using Content.Shared.Actions.Components;
using Content.Shared.Cooldown;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -27,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 string? 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
@@ -68,8 +69,7 @@ namespace Content.Server.Actions.Spells
handsComponent.PutInHandOrDrop(itemComponent);
if (CastSound != null)
SoundSystem.Play(Filter.Pvs(caster), CastSound, caster);
SoundSystem.Play(Filter.Pvs(caster), CastSound.GetSound(), caster);
}
}
}

View File

@@ -6,6 +6,7 @@ using Content.Server.WireHacking;
using Content.Shared.ActionBlocker;
using Content.Shared.Arcade;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.Wires;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -37,18 +38,33 @@ namespace Content.Server.Arcade.Components
[ViewVariables] private bool _enemyInvincibilityFlag;
[ViewVariables] private SpaceVillainGame _game = null!;
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFightVerbs")] private List<string> _possibleFightVerbs = new List<string>()
[DataField("newGameSound")] private SoundSpecifier _newGameSound = new SoundPathSpecifier("/Audio/Effects/Arcade/newgame.ogg");
[DataField("playerAttackSound")] private SoundSpecifier _playerAttackSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_attack.ogg");
[DataField("playerHealSound")] private SoundSpecifier _playerHealSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_heal.ogg");
[DataField("playerChargeSound")] private SoundSpecifier _playerChargeSound = new SoundPathSpecifier("/Audio/Effects/Arcade/player_charge.ogg");
[DataField("winSound")] private SoundSpecifier _winSound = new SoundPathSpecifier("/Audio/Effects/Arcade/win.ogg");
[DataField("gameOverSound")] private SoundSpecifier _gameOverSound = new SoundPathSpecifier("/Audio/Effects/Arcade/gameover.ogg");
[ViewVariables(VVAccess.ReadWrite)]
[DataField("possibleFightVerbs")]
private List<string> _possibleFightVerbs = new List<string>()
{"Defeat", "Annihilate", "Save", "Strike", "Stop", "Destroy", "Robust", "Romance", "Pwn", "Own"};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleFirstEnemyNames")] private List<string> _possibleFirstEnemyNames = new List<string>(){
[ViewVariables(VVAccess.ReadWrite)]
[DataField("possibleFirstEnemyNames")]
private List<string> _possibleFirstEnemyNames = new List<string>(){
"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<string> _possibleLastEnemyNames = new List<string>()
[ViewVariables(VVAccess.ReadWrite)]
[DataField("possibleLastEnemyNames")]
private List<string> _possibleLastEnemyNames = new List<string>()
{
"Melonoid", "Murdertron", "Sorcerer", "Ruin", "Jeff", "Ectoplasm", "Crushulon", "Uhangoid",
"Vhakoid", "Peteoid", "slime", "Griefer", "ERPer", "Lizard Man", "Unicorn"
};
[ViewVariables(VVAccess.ReadWrite)] [DataField("possibleRewards")] private List<string> _possibleRewards = new List<string>()
[ViewVariables(VVAccess.ReadWrite)]
[DataField("possibleRewards")]
private List<string> _possibleRewards = new List<string>()
{
"ToyMouse", "ToyAi", "ToyNuke", "ToyAssistant", "ToyGriffin", "ToyHonk", "ToyIan",
"ToyMarauder", "ToyMauler", "ToyGygax", "ToyOdysseus", "ToyOwlman", "ToyDeathRipley",
@@ -57,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<ActionBlockerSystem>().CanInteract(eventArgs.User))
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
return;
_game ??= new SpaceVillainGame(this);
@@ -68,7 +84,8 @@ namespace Content.Server.Arcade.Components
if (_wiresComponent?.IsPanelOpen == true)
{
_wiresComponent.OpenInterface(actor.PlayerSession);
} else
}
else
{
UserInterface?.Toggle(actor.PlayerSession);
}
@@ -97,7 +114,7 @@ namespace Content.Server.Arcade.Components
private void OnOnPowerStateChanged(PowerChangedMessage e)
{
if(e.Powered) return;
if (e.Powered) return;
UserInterface?.CloseAll();
}
@@ -122,7 +139,8 @@ namespace Content.Server.Arcade.Components
_game?.ExecutePlayerAction(msg.PlayerAction);
break;
case PlayerAction.NewGame:
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/Arcade/newgame.ogg", 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());
break;
@@ -250,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)
{
@@ -267,7 +285,7 @@ namespace Content.Server.Arcade.Components
/// </summary>
private void ValidateVars()
{
if(_owner._overflowFlag) return;
if (_owner._overflowFlag) return;
if (_playerHp > _playerHpMax) _playerHp = _playerHpMax;
if (_playerMp > _playerMpMax) _playerMp = _playerMpMax;
@@ -290,8 +308,9 @@ namespace Content.Server.Arcade.Components
_latestPlayerActionMessage = Loc.GetString("space-villain-game-player-attack-message",
("enemyName", _enemyName),
("attackAmount", attackAmount));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_attack.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!_owner._enemyInvincibilityFlag) _enemyHp -= attackAmount;
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;
case PlayerAction.Heal:
@@ -300,15 +319,16 @@ namespace Content.Server.Arcade.Components
_latestPlayerActionMessage = Loc.GetString("space-villain-game-player-heal-message",
("magicPointAmount", pointAmount),
("healAmount", healAmount));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_heal.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
if(!_owner._playerInvincibilityFlag) _playerMp -= pointAmount;
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));
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/player_charge.ogg", _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;
@@ -340,9 +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);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/win.ogg", _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;
}
@@ -353,9 +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);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _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)
@@ -364,7 +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);
SoundSystem.Play(Filter.Pvs(_owner.Owner), "/Audio/Effects/Arcade/gameover.ogg", _owner.Owner, AudioParams.Default.WithVolume(-4f));
SoundSystem.Play(Filter.Pvs(_owner.Owner), _owner._gameOverSound.GetSound(), _owner.Owner, AudioParams.Default.WithVolume(-4f));
return false;
}
@@ -401,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",
@@ -410,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;

View File

@@ -15,6 +15,7 @@ using Content.Shared.Audio;
using Content.Shared.DragDrop;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -45,6 +46,8 @@ namespace Content.Server.Atmos.Components
[ViewVariables] private BoundUserInterface? _userInterface;
[DataField("ruptureSound")] private SoundSpecifier _ruptureSound = new SoundPathSpecifier("Audio/Effects/spray.ogg");
[DataField("air")] [ViewVariables] public GasMixture Air { get; set; } = new();
/// <summary>
@@ -280,8 +283,7 @@ namespace Content.Server.Atmos.Components
if(environment != null)
atmosphereSystem.Merge(environment, Air);
SoundSystem.Play(Filter.Pvs(Owner), "Audio/Effects/spray.ogg", Owner.Transform.Coordinates,
AudioHelpers.WithVariation(0.125f));
SoundSystem.Play(Filter.Pvs(Owner), _ruptureSound.GetSound(), Owner.Transform.Coordinates, AudioHelpers.WithVariation(0.125f));
Owner.QueueDelete();
return;

View File

@@ -8,6 +8,7 @@ using Content.Shared.Body.Slot;
using Content.Shared.MobState;
using Content.Shared.Movement.Components;
using Content.Shared.Random.Helpers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -15,6 +16,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Body
{
@@ -25,6 +27,8 @@ namespace Content.Server.Body
{
private Container _partContainer = default!;
[DataField("gibSound")] private SoundSpecifier _gibSound = new SoundCollectionSpecifier("gib");
protected override bool CanAddPart(string slotId, SharedBodyPartComponent part)
{
return base.CanAddPart(slotId, part) &&
@@ -100,8 +104,7 @@ namespace Content.Server.Body
{
base.Gib(gibParts);
SoundSystem.Play(Filter.Pvs(Owner), AudioHelpers.GetRandomFileFromSoundCollection("gib"), 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))
{

View File

@@ -723,10 +723,7 @@ namespace Content.Server.Botany.Components
sprayed = true;
amount = ReagentUnit.New(1);
if (!string.IsNullOrEmpty(spray.SpraySound))
{
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound, usingItem, AudioHelpers.WithVariation(0.125f));
}
SoundSystem.Play(Filter.Pvs(usingItem), spray.SpraySound.GetSound(), usingItem, AudioHelpers.WithVariation(0.125f));
}
var split = solution.Drain(amount);

View File

@@ -50,7 +50,7 @@ namespace Content.Server.Buckle.Components
/// </summary>
[DataField("delay")]
[ViewVariables]
private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f);
private TimeSpan _unbuckleDelay = TimeSpan.FromSeconds(0.25f);
/// <summary>
/// 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,13 +241,13 @@ namespace Content.Server.Buckle.Components
return false;
}
SoundSystem.Play(Filter.Pvs(Owner), strap.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;
}
@@ -349,7 +349,7 @@ namespace Content.Server.Buckle.Components
UpdateBuckleStatus();
oldBuckledTo.Remove(this);
SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound.GetSound(), Owner);
SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner));

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
using Content.Server.Hands.Components;
using Content.Server.Hands.Components;
using Content.Server.Items;
using Content.Shared.Audio;
using Content.Shared.Cabinet;
@@ -36,7 +36,7 @@ namespace Content.Server.Cabinet
comp.ItemContainer =
owner.EnsureContainer<ContainerSlot>("item_cabinet", out _);
if(comp.SpawnPrototype != null)
if (comp.SpawnPrototype != null)
comp.ItemContainer.Insert(EntityManager.SpawnEntity(comp.SpawnPrototype, owner.Transform.Coordinates));
UpdateVisuals(comp);
@@ -146,8 +146,7 @@ namespace Content.Server.Cabinet
private static void ClickLatchSound(ItemCabinetComponent comp)
{
if (comp.DoorSound == null) return;
SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound, comp.Owner, AudioHelpers.WithVariation(0.15f));
SoundSystem.Play(Filter.Pvs(comp.Owner), comp.DoorSound.GetSound(), comp.Owner, AudioHelpers.WithVariation(0.15f));
}
}

View File

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

View File

@@ -1,10 +1,12 @@
using System.Collections.Generic;
using Content.Server.Power.Components;
using Content.Shared.Cargo;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Cargo.Components
{
@@ -20,6 +22,7 @@ namespace Content.Server.Cargo.Components
private const float TeleportDelay = 15f;
private List<CargoProductPrototype> _teleportQueue = new List<CargoProductPrototype>();
private CargoTelepadState _currentState = CargoTelepadState.Unpowered;
[DataField("teleportSound")] private SoundSpecifier _teleportSound = new SoundPathSpecifier("/Audio/Machines/phasein.ogg");
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
@@ -71,7 +74,7 @@ namespace Content.Server.Cargo.Components
{
if (!Deleted && !Owner.Deleted && _currentState == CargoTelepadState.Teleporting && _teleportQueue.Count > 0)
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/phasein.ogg", 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<SpriteComponent>(out var spriteComponent) && spriteComponent.LayerCount > 0)

View File

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

View File

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

View File

@@ -7,6 +7,7 @@ using Content.Shared.Chemistry.Reagent;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
@@ -22,8 +23,8 @@ namespace Content.Server.Chemistry.Components
public override string Name => "Pill";
[ViewVariables]
[DataField("useSound")]
protected override string? UseSound { get; set; } = default;
[DataField("useSound", required: true)]
protected override SoundSpecifier UseSound { get; set; } = default!;
[ViewVariables]
[DataField("trash")]
@@ -98,10 +99,7 @@ namespace Content.Server.Chemistry.Components
firstStomach.TryTransferSolution(split);
if (UseSound != null)
{
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("pill-component-swallow-success-message"));

View File

@@ -13,6 +13,7 @@ using Content.Shared.Chemistry.Reagent;
using Content.Shared.Chemistry.Solution;
using Content.Shared.Interaction;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -46,6 +47,9 @@ 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");
[ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null;
[ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10);
[UsedImplicitly] [ViewVariables] private SolutionContainerComponent? Solution => _beakerContainer.ContainedEntity?.GetComponent<SolutionContainerComponent>();
@@ -358,7 +362,7 @@ namespace Content.Server.Chemistry.Components
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
[Verb]

View File

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

View File

@@ -3,6 +3,7 @@ using Content.Server.Chemistry.Components;
using Content.Server.Coordinates.Helpers;
using Content.Shared.Audio;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -79,7 +80,7 @@ namespace Content.Server.Chemistry.ReactionEffects
/// <summary>
/// Sound that will get played when this reaction effect occurs.
/// </summary>
[DataField("sound")] private string? _sound;
[DataField("sound", required: true)] private SoundSpecifier _sound = default!;
protected AreaReactionEffect()
{
@@ -135,10 +136,7 @@ namespace Content.Server.Chemistry.ReactionEffects
areaEffectComponent.TryAddSolution(solution);
areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay);
if (!string.IsNullOrEmpty(_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);

View File

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

View File

@@ -8,6 +8,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -29,8 +30,8 @@ namespace Content.Server.Crayon
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
//TODO: useSound
[DataField("useSound")]
private string? _useSound = string.Empty;
[DataField("useSound", required: true)]
private SoundSpecifier _useSound = default!;
[ViewVariables]
public Color Color { get; set; }
@@ -138,10 +139,7 @@ namespace Content.Server.Crayon
appearance.SetData(CrayonVisuals.Rotation, eventArgs.User.Transform.LocalRotation);
}
if (!string.IsNullOrEmpty(_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--;

View File

@@ -231,13 +231,11 @@ namespace Content.Server.Cuffs.Components
if (isOwner)
{
if (cuff.StartBreakoutSound != null)
SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), cuff.StartBreakoutSound.GetSound(), Owner);
}
else
{
if (cuff.StartUncuffSound != null)
SoundSystem.Play(Filter.Pvs(Owner), cuff.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 != null)
SoundSystem.Play(Filter.Pvs(Owner), cuff.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)));
}
}
}

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
@@ -113,18 +114,19 @@ namespace Content.Server.Cuffs.Components
}
[DataField("startCuffSound")]
public string StartCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_start.ogg";
public SoundSpecifier StartCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_start.ogg");
[DataField("endCuffSound")] public string EndCuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_end.ogg";
[DataField("endCuffSound")]
public SoundSpecifier EndCuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_end.ogg");
[DataField("startBreakoutSound")]
public string StartBreakoutSound { get; set; } = "/Audio/Items/Handcuffs/cuff_breakout_start.ogg";
public SoundSpecifier StartBreakoutSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_breakout_start.ogg");
[DataField("startUncuffSound")]
public string StartUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_start.ogg";
public SoundSpecifier StartUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_start.ogg");
[DataField("endUncuffSound")]
public string EndUncuffSound { get; set; } = "/Audio/Items/Handcuffs/cuff_takeoff_end.ogg";
public SoundSpecifier EndUncuffSound { get; set; } = new SoundPathSpecifier("/Audio/Items/Handcuffs/cuff_takeoff_end.ogg");
[DataField("color")]
public Color Color { get; set; } = Color.White;
@@ -183,8 +185,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 != null)
SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), StartCuffSound.GetSound(), Owner);
TryUpdateCuff(eventArgs.User, eventArgs.Target, cuffed);
return true;
@@ -221,8 +222,7 @@ namespace Content.Server.Cuffs.Components
{
if (cuffs.TryAddNewCuffs(user, Owner))
{
if (EndCuffSound != null)
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)));

View File

@@ -1,5 +1,6 @@
using System;
using System;
using Content.Shared.Damage;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -21,8 +22,8 @@ namespace Content.Server.Damage.Components
public int BaseDamage { get; set; } = 5;
[DataField("factor")]
public float Factor { get; set; } = 1f;
[DataField("soundHit")]
public string SoundHit { get; set; } = "";
[DataField("soundHit", required: true)]
public SoundSpecifier SoundHit { get; set; } = default!;
[DataField("stunChance")]
public float StunChance { get; set; } = 0.25f;
[DataField("stunMinimumDamage")]

View File

@@ -34,8 +34,7 @@ namespace Content.Server.Damage
if (speed < component.MinimumSpeed) return;
if (!string.IsNullOrEmpty(component.SoundHit))
SoundSystem.Play(Filter.Pvs(otherBody), component.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;

View File

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

View File

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

View File

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

View File

@@ -8,6 +8,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Robust.Server.Console;
using Robust.Server.GameObjects;
@@ -19,6 +20,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
@@ -41,6 +43,8 @@ namespace Content.Server.Disposal.Tube.Components
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
public override Direction NextDirection(DisposalHolderComponent holder)
{
var directions = ConnectableDirections();
@@ -123,7 +127,7 @@ namespace Content.Server.Disposal.Tube.Components
/// <returns>Returns a <see cref="DisposalRouterUserInterfaceState"/></returns>
private DisposalRouterUserInterfaceState GetUserInterfaceState()
{
if(_tags.Count <= 0)
if (_tags.Count <= 0)
{
return new DisposalRouterUserInterfaceState("");
}
@@ -149,7 +153,7 @@ namespace Content.Server.Disposal.Tube.Components
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
/// <summary>

View File

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

View File

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

View File

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

View File

@@ -295,7 +295,7 @@ namespace Content.Server.Doors.Components
public void WiresUpdate(WiresUpdateEventArgs args)
{
if(DoorComponent == null)
if (DoorComponent == null)
{
return;
}

View File

@@ -42,6 +42,9 @@ namespace Content.Server.Doors.Components
[DataField("board")]
private string? _boardPrototype;
[DataField("tryOpenDoorSound")]
private SoundSpecifier _tryOpenDoorSound = new SoundPathSpecifier("/Audio/Effects/bang.ogg");
public override DoorState State
{
get => base.State;
@@ -251,8 +254,7 @@ namespace Content.Server.Doors.Components
if (user.TryGetComponent(out HandsComponent? hands) && hands.Count == 0)
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/bang.ogg", Owner,
AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), _tryOpenDoorSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2));
}
}
else

View File

@@ -14,7 +14,7 @@ namespace Content.Server.Explosion.Components
public override string Name => "SoundOnTrigger";
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sound")]
public SoundSpecifier? Sound { get; set; } = null;
[DataField("sound", required: true)]
public SoundSpecifier Sound { get; set; } = default!;
}
}

View File

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

View File

@@ -5,10 +5,12 @@ using Content.Shared.Chemistry.Solution.Components;
using Content.Shared.Interaction;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Extinguisher
@@ -18,6 +20,8 @@ namespace Content.Server.Extinguisher
{
public override string Name => "FireExtinguisher";
[DataField("refillSound")] SoundSpecifier _refillSound = new SoundPathSpecifier("/Audio/Effects/refill.ogg");
// Higher priority than sprays.
int IAfterInteract.Priority => 1;
@@ -39,7 +43,7 @@ namespace Content.Server.Extinguisher
var drained = targetSolution.Drain(trans);
container.TryAddSolution(drained);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/refill.ogg", 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)));
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,6 +10,7 @@ using Content.Shared.DragDrop;
using Content.Shared.Fluids;
using Content.Shared.Interaction;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Content.Shared.Vapor;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -34,8 +35,6 @@ namespace Content.Server.Fluids.Components
[DataField("transferAmount")]
private ReagentUnit _transferAmount = ReagentUnit.New(10);
[DataField("spraySound")]
private string? _spraySound;
[DataField("sprayVelocity")]
private float _sprayVelocity = 1.5f;
[DataField("sprayAliveTime")]
@@ -77,7 +76,8 @@ namespace Content.Server.Fluids.Components
set => _sprayVelocity = value;
}
public string? SpraySound => _spraySound;
[DataField("spraySound", required: true)]
public SoundSpecifier SpraySound { get; } = default!;
public ReagentUnit CurrentVolume => Owner.GetComponentOrNull<SolutionContainerComponent>()?.CurrentVolume ?? ReagentUnit.Zero;
@@ -173,11 +173,7 @@ namespace Content.Server.Fluids.Components
}
}
//Play sound
if (!string.IsNullOrEmpty(_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);

View File

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

View File

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

View File

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

View File

@@ -12,6 +12,7 @@ using Content.Shared.Body.Part;
using Content.Shared.Hands.Components;
using Content.Shared.Notification.Managers;
using Content.Shared.Pulling.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -20,6 +21,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Hands.Components
{
@@ -31,6 +33,8 @@ namespace Content.Server.Hands.Components
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[DataField("disarmedSound")] SoundSpecifier _disarmedSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
int IDisarmedAct.Priority => int.MaxValue; // We want this to be the last disarm act to run.
protected override void OnHeldEntityRemovedFromHand(IEntity heldEntity, HandState handState)
@@ -135,8 +139,7 @@ namespace Content.Server.Hands.Components
if (source != null)
{
SoundSystem.Play(Filter.Pvs(source), "/Audio/Effects/thudswoosh.ogg", source,
AudioHelpers.WithVariation(0.025f));
SoundSystem.Play(Filter.Pvs(source), _disarmedSound.GetSound(), source, AudioHelpers.WithVariation(0.025f));
if (target != null)
{

View File

@@ -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 != null)
SoundSystem.Play(Filter.Pvs(Owner), SpikeSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), SpikeSound.GetSound(), Owner);
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

@@ -23,6 +23,7 @@ using Content.Shared.Kitchen.Components;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Power;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -49,12 +50,14 @@ namespace Content.Server.Kitchen.Components
[DataField("failureResult")]
private string _badRecipeName = "FoodBadRecipe";
[DataField("beginCookingSound")]
private string _startCookingSound = "/Audio/Machines/microwave_start_beep.ogg";
private SoundSpecifier _startCookingSound = new SoundPathSpecifier("/Audio/Machines/microwave_start_beep.ogg");
[DataField("foodDoneSound")]
private string _cookingCompleteSound = "/Audio/Machines/microwave_done_beep.ogg";
#endregion
private SoundSpecifier _cookingCompleteSound = new SoundPathSpecifier("/Audio/Machines/microwave_done_beep.ogg");
[DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
#endregion YAMLSERIALIZE
[ViewVariables]
[ViewVariables]
private bool _busy = false;
private bool _broken;
@@ -104,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();
@@ -268,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;
}
@@ -297,14 +300,14 @@ namespace Content.Server.Kitchen.Components
_busy = true;
// Convert storage into Dictionary of ingredients
var solidsDict = new Dictionary<string, int>();
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]++;
}
@@ -315,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;
}
@@ -334,15 +337,15 @@ namespace Content.Server.Kitchen.Components
}
SetAppearance(MicrowaveVisualState.Cooking);
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound, Owner, AudioParams.Default);
Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() =>
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default);
Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), (Action) (() =>
{
if (_lostPower)
{
return;
}
if(failState == MicrowaveSuccessState.UnwantedForeignObject)
if (failState == MicrowaveSuccessState.UnwantedForeignObject)
{
VaporizeReagents();
EjectSolids();
@@ -361,7 +364,9 @@ namespace Content.Server.Kitchen.Components
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
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;
@@ -390,7 +395,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);
@@ -401,7 +406,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));
}
@@ -423,7 +428,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));
}
@@ -451,7 +456,7 @@ namespace Content.Server.Kitchen.Components
}
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string,int> solids)
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids)
{
if (_currentCookTimerTime != (uint) recipe.CookTime)
{
@@ -494,7 +499,7 @@ namespace Content.Server.Kitchen.Components
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
@@ -530,7 +535,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);

View File

@@ -1,6 +1,7 @@
using Content.Server.Chemistry.Components;
using Content.Shared.Interaction;
using Content.Shared.Kitchen.Components;
using Content.Shared.Sound;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -38,5 +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")] 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");
}
}

View File

@@ -278,7 +278,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) (() =>
{
@@ -301,7 +301,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())
@@ -327,7 +327,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));
}
}
}

View File

@@ -100,11 +100,8 @@ namespace Content.Server.Light.Components
switch (CurrentState)
{
case ExpendableLightState.Lit:
if (LitSound != string.Empty)
{
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 != string.Empty)
{
SoundSystem.Play(Filter.Pvs(Owner), DieSound, Owner);
}
SoundSystem.Play(Filter.Pvs(Owner), DieSound.GetSound(), Owner);
sprite.LayerSetState(0, IconStateSpent);
sprite.LayerSetShader(0, "shaded");

View File

@@ -12,6 +12,7 @@ using Content.Shared.Interaction.Events;
using Content.Shared.Light.Component;
using Content.Shared.Notification.Managers;
using Content.Shared.Rounding;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -45,9 +46,9 @@ namespace Content.Server.Light.Components
[ViewVariables] protected override bool HasCell => _cellSlot.HasCell;
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public string? TurnOnSound = "/Audio/Items/flashlight_toggle.ogg";
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public string? TurnOnFailSound = "/Audio/Machines/button.ogg";
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public string? TurnOffSound = "/Audio/Items/flashlight_toggle.ogg";
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnSound")] public SoundSpecifier TurnOnSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOnFailSound")] public SoundSpecifier TurnOnFailSound = new SoundPathSpecifier("/Audio/Machines/button.ogg");
[ViewVariables(VVAccess.ReadWrite)] [DataField("turnOffSound")] public SoundSpecifier TurnOffSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[ComponentDependency] private readonly ItemActionsComponent? _itemActions = null;
@@ -121,7 +122,7 @@ namespace Content.Server.Light.Components
if (makeNoise)
{
if (TurnOffSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOffSound.GetSound(), Owner);
}
return true;
@@ -136,7 +137,7 @@ namespace Content.Server.Light.Components
if (Cell == null)
{
if (TurnOnFailSound != null) 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;
@@ -147,7 +148,7 @@ namespace Content.Server.Light.Components
// Simple enough.
if (Wattage > Cell.CurrentCharge)
{
if (TurnOnFailSound != null) 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;
@@ -158,7 +159,7 @@ namespace Content.Server.Light.Components
SetState(true);
Owner.EntityManager.EventBus.QueueEvent(EventSource.Local, new ActivateHandheldLightMessage(this));
if (TurnOnSound != null) SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), TurnOnSound.GetSound(), Owner);
return true;
}

View File

@@ -1,6 +1,7 @@
using System;
using Content.Shared.Acts;
using Content.Shared.Audio;
using Content.Shared.Sound;
using Content.Shared.Throwing;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -46,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
@@ -70,11 +72,15 @@ namespace Content.Server.Light.Components
private int _powerUse = 40;
public int PowerUse => _powerUse;
[DataField("breakSound")]
private SoundSpecifier _breakSound = new SoundCollectionSpecifier("GlassBreak");
/// <summary>
/// The current state of the light bulb. Invokes the OnLightBulbStateChange event when set.
/// It also updates the bulb's sprite accordingly.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] public LightBulbState State
[ViewVariables(VVAccess.ReadWrite)]
public LightBulbState State
{
get { return _state; }
set
@@ -128,10 +134,7 @@ namespace Content.Server.Light.Components
public void PlayBreakSound()
{
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>("GlassBreak");
var file = _random.Pick(soundCollection.PickFiles);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner);
SoundSystem.Play(Filter.Pvs(Owner), _breakSound.GetSound(), Owner);
}
}
}

View File

@@ -2,6 +2,7 @@ using System.Threading.Tasks;
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Smoking;
using Content.Shared.Sound;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
@@ -23,13 +24,14 @@ namespace Content.Server.Light.Components
/// <summary>
/// How long will matchstick last in seconds.
/// </summary>
[ViewVariables(VVAccess.ReadOnly)] [DataField("duration")]
[ViewVariables(VVAccess.ReadOnly)]
[DataField("duration")]
private int _duration = 10;
/// <summary>
/// Sound played when you ignite the matchstick.
/// </summary>
[DataField("igniteSound")] private string? _igniteSound;
[DataField("igniteSound", required: true)] private SoundSpecifier _igniteSound = default!;
/// <summary>
/// Point light component. Gives matches a glow in dark effect.
@@ -68,11 +70,9 @@ namespace Content.Server.Light.Components
public void Ignite(IEntity user)
{
// Play Sound
if (!string.IsNullOrEmpty(_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;

View File

@@ -14,6 +14,7 @@ using Content.Shared.Interaction;
using Content.Shared.Light;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -48,10 +49,17 @@ namespace Content.Server.Light.Components
private TimeSpan _lastThunk;
private TimeSpan? _lastGhostBlink;
[DataField("burnHandSound")]
private SoundSpecifier _burnHandSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");
[DataField("turnOnSound")]
private SoundSpecifier _turnOnSound = new SoundPathSpecifier("/Audio/Machines/light_tube_on.ogg");
[DataField("hasLampOnSpawn")]
private bool _hasLampOnSpawn = true;
[ViewVariables] [DataField("on")]
[ViewVariables]
[DataField("on")]
private bool _on = true;
[ViewVariables]
@@ -60,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;
@@ -95,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;
@@ -118,7 +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);
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/lightburn.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), _burnHandSound.GetSound(), Owner);
}
void Eject()
@@ -220,7 +229,7 @@ namespace Content.Server.Light.Components
if (time > _lastThunk + _thunkDelay)
{
_lastThunk = time;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/light_tube_on.ogg", Owner, AudioParams.Default.WithVolume(-10f));
SoundSystem.Play(Filter.Pvs(Owner), _turnOnSound.GetSound(), Owner, AudioParams.Default.WithVolume(-10f));
}
}
else
@@ -329,7 +338,8 @@ namespace Content.Server.Light.Components
_lastGhostBlink = time;
ToggleBlinkingLight(true);
Owner.SpawnTimer(ghostBlinkingTime, () => {
Owner.SpawnTimer(ghostBlinkingTime, () =>
{
ToggleBlinkingLight(false);
});

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -14,6 +14,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Nutrition.Components;
using Content.Shared.Sound;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -45,7 +46,7 @@ namespace Content.Server.Nutrition.Components
[ViewVariables]
[DataField("useSound")]
private string _useSound = "/Audio/Items/drink.ogg";
private SoundSpecifier _useSound = new SoundPathSpecifier("/Audio/Items/drink.ogg");
[ViewVariables]
[DataField("isOpen")]
@@ -74,11 +75,11 @@ namespace Content.Server.Nutrition.Components
public bool Empty => Owner.GetComponentOrNull<ISolutionInteractionsComponent>()?.DrainAvailable <= 0;
[DataField("openSounds")]
private string _soundCollection = "canOpenSounds";
private SoundSpecifier _openSounds = new SoundCollectionSpecifier("canOpenSounds");
[DataField("pressurized")]
private bool _pressurized = default;
[DataField("burstSound")]
private string _burstSound = "/Audio/Effects/flash_bang.ogg";
private SoundSpecifier _burstSound = new SoundPathSpecifier("/Audio/Effects/flash_bang.ogg");
protected override void Initialize()
{
@@ -126,10 +127,8 @@ namespace Content.Server.Nutrition.Components
if (!Opened)
{
//Do the opening stuff like playing the sounds.
var soundCollection = _prototypeManager.Index<SoundCollectionPrototype>(_soundCollection);
var file = _random.Pick(soundCollection.PickFiles);
SoundSystem.Play(Filter.Pvs(args.User), _openSounds.GetSound(), args.User, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(args.User), file, 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<StomachBehavior>(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 (!string.IsNullOrEmpty(_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");
SoundSystem.Play(Filter.Pvs(Owner), _burstSound, Owner,
AudioParams.Default.WithVolume(-4));
SoundSystem.Play(Filter.Pvs(Owner), _burstSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4));
}
}
}

View File

@@ -12,6 +12,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
@@ -29,7 +30,7 @@ namespace Content.Server.Nutrition.Components
{
public override string Name => "Food";
[ViewVariables] [DataField("useSound")] protected virtual string? UseSound { get; set; } = "/Audio/Items/eatfood.ogg";
[ViewVariables] [DataField("useSound")] protected virtual SoundSpecifier UseSound { get; set; } = new SoundPathSpecifier("/Audio/Items/eatfood.ogg");
[ViewVariables] [DataField("trash", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] protected virtual string? TrashPrototype { get; set; }
@@ -49,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()));
}
}
@@ -109,7 +110,7 @@ namespace Content.Server.Nutrition.Components
}
var utensils = utensilUsed != null
? new List<UtensilComponent> {utensilUsed}
? new List<UtensilComponent> { utensilUsed }
: null;
if (_utensilsNeeded != UtensilType.None)
@@ -159,10 +160,7 @@ namespace Content.Server.Nutrition.Components
firstStomach.TryTransferSolution(split);
if (UseSound != null)
{
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"));

View File

@@ -5,6 +5,7 @@ using Content.Server.Items;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -23,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)]
private string _sound = "/Audio/Items/Culinary/chop.ogg";
[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;
@@ -66,7 +70,7 @@ namespace Content.Server.Nutrition.Components
}
}
SoundSystem.Play(Filter.Pvs(Owner), _sound, Owner.Transform.Coordinates,
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner.Transform.Coordinates,
AudioParams.Default.WithVolume(-2));
Count--;

View File

@@ -2,6 +2,7 @@ using System;
using System.Threading.Tasks;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Helpers;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -46,7 +47,7 @@ namespace Content.Server.Nutrition.Components
/// </summary>
[ViewVariables]
[DataField("breakSound")]
private string? _breakSound = "/Audio/Items/snap.ogg";
private SoundSpecifier _breakSound = new SoundPathSpecifier("/Audio/Items/snap.ogg");
public void AddType(UtensilType type)
{
@@ -70,9 +71,9 @@ namespace Content.Server.Nutrition.Components
internal void TryBreak(IEntity user)
{
if (_breakSound != null && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
if (IoCManager.Resolve<IRobustRandom>().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();
}
}

View File

@@ -14,6 +14,7 @@ using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Notification.Managers;
using Content.Shared.PDA;
using Content.Shared.Sound;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
@@ -58,6 +59,10 @@ namespace Content.Server.PDA
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(PDAUiKey.Key);
[DataField("insertIdSound")] private SoundSpecifier _insertIdSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg");
[DataField("toggleFlashlightSound")] private SoundSpecifier _toggleFlashlightSound = new SoundPathSpecifier("/Audio/Items/flashlight_toggle.ogg");
[DataField("ejectIdSound")] private SoundSpecifier _ejectIdSound = new SoundPathSpecifier("/Audio/Machines/id_swipe.ogg");
public PDAComponent()
{
_accessSet = new PdaAccessSet(this);
@@ -124,8 +129,7 @@ namespace Content.Server.PDA
case PDAUplinkBuyListingMessage buyMsg:
{
var player = message.Session.AttachedEntity;
if (player == null)
break;
if (player == null) break;
if (!_uplinkManager.TryPurchaseItem(_syndicateUplinkAccount, buyMsg.ItemId,
player.Transform.Coordinates, out var entity))
@@ -134,7 +138,8 @@ namespace Content.Server.PDA
break;
}
if (!player.TryGetComponent(out HandsComponent? hands) || !entity.TryGetComponent(out ItemComponent? item))
if (!player.TryGetComponent(out HandsComponent? hands) ||
!entity.TryGetComponent(out ItemComponent? item))
break;
hands.PutInHandOrDrop(item);
@@ -300,7 +305,7 @@ namespace Content.Server.PDA
{
_idSlot.Insert(card.Owner);
ContainedID = card;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Weapons/Guns/MagIn/batrifle_magin.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), _insertIdSound.GetSound(), Owner);
}
/// <summary>
@@ -329,7 +334,7 @@ namespace Content.Server.PDA
_lightOn = !_lightOn;
light.Enabled = _lightOn;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/flashlight_toggle.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), _toggleFlashlightSound.GetSound(), Owner);
UpdatePDAUserInterface();
}
@@ -348,7 +353,7 @@ namespace Content.Server.PDA
hands.PutInHandOrDrop(cardItemComponent);
ContainedID = null;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/id_swipe.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), _ejectIdSound.GetSound(), Owner);
UpdatePDAUserInterface();
}

View File

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

View File

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

View File

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

View File

@@ -5,6 +5,7 @@ using Content.Server.UserInterface;
using Content.Shared.APC;
using Content.Shared.Interaction;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -12,6 +13,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -27,6 +29,8 @@ namespace Content.Server.Power.Components
public bool MainBreakerEnabled { get; private set; } = true;
[DataField("onReceiveMessageSound")] private SoundSpecifier _onReceiveMessageSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
private ApcChargeState _lastChargeState;
private TimeSpan _lastChargeStateChange;
@@ -81,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))
{
@@ -89,7 +93,7 @@ namespace Content.Server.Power.Components
Owner.GetComponent<PowerNetworkBatteryComponent>().CanDischarge = MainBreakerEnabled;
_uiDirty = true;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg", Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _onReceiveMessageSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
else
{

View File

@@ -5,6 +5,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Audio;
using Content.Shared.Examine;
using Content.Shared.Interaction.Events;
using Content.Shared.Sound;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -62,7 +63,7 @@ namespace Content.Server.PowerCell.Components
/// <example>"/Audio/Items/pistol_magout.ogg"</example>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("cellRemoveSound")]
public string? CellRemoveSound { get; set; } = "/Audio/Items/pistol_magin.ogg";
public SoundSpecifier CellRemoveSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magin.ogg");
/// <summary>
/// File path to a sound file that should be played when a cell is inserted.
@@ -70,7 +71,7 @@ namespace Content.Server.PowerCell.Components
/// <example>"/Audio/Items/pistol_magin.ogg"</example>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("cellInsertSound")]
public string? CellInsertSound { get; set; } = "/Audio/Items/pistol_magout.ogg";
public SoundSpecifier CellInsertSound { get; set; } = new SoundPathSpecifier("/Audio/Items/pistol_magout.ogg");
[ViewVariables] private ContainerSlot _cellContainer = default!;
@@ -143,9 +144,9 @@ namespace Content.Server.PowerCell.Components
cell.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
}
if (playSound && CellRemoveSound != null)
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);
@@ -166,9 +167,9 @@ namespace Content.Server.PowerCell.Components
if (cellComponent.CellSize != SlotSize) return false;
if (!_cellContainer.Insert(cell)) return false;
//Dirty();
if (playSound && CellInsertSound != null)
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);

View File

@@ -1,6 +1,7 @@
using System;
using Content.Shared.Damage;
using Content.Shared.Physics;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -50,7 +51,7 @@ namespace Content.Server.Projectiles.Components
[DataField("impactFlash")]
private string? _impactFlash;
[DataField("soundHitWall")]
private string _soundHitWall = "/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg";
private SoundSpecifier _soundHitWall = new SoundPathSpecifier("/Audio/Weapons/Guns/Hits/laser_sear_wall.ogg");
public void FireEffects(IEntity user, float distance, Angle angle, IEntity? hitEntity = null)
{
@@ -85,7 +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);
SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall, coordinates);
SoundSystem.Play(Filter.Pvs(coordinates), _soundHitWall.GetSound(), coordinates);
}
Owner.SpawnTimer((int) _deathTime.TotalMilliseconds, () =>

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Content.Shared.Damage;
using Content.Shared.Projectiles;
using Content.Shared.Sound;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -25,8 +26,8 @@ namespace Content.Server.Projectiles.Components
public bool DeleteOnCollide { get; } = true;
// Get that juicy FPS hit sound
[DataField("soundHit")] public string? SoundHit = default;
[DataField("soundHitSpecies")] public string? SoundHitSpecies = default;
[DataField("soundHit", required: true)] public SoundSpecifier SoundHit = default!;
[DataField("soundHitSpecies", required: true)] public SoundSpecifier SoundHitSpecies = default!;
public bool DamagedEntity;

View File

@@ -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<SharedBodyComponent>() && component.SoundHitSpecies != null)
if (!otherEntity.Deleted && otherEntity.HasComponent<SharedBodyComponent>())
{
SoundSystem.Play(playerFilter, component.SoundHitSpecies, coordinates);
SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates);
}
else if (component.SoundHit != null)
else
{
SoundSystem.Play(playerFilter, component.SoundHit, coordinates);
SoundSystem.Play(playerFilter, component.SoundHit.GetSound(), coordinates);
}
if (!otherEntity.Deleted && otherEntity.TryGetComponent(out IDamageableComponent? damage))

View File

@@ -9,6 +9,7 @@ using Content.Shared.Interaction.Helpers;
using Content.Shared.Maps;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
@@ -32,12 +33,18 @@ 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;
private DoAfterSystem _doAfterSystem = default!;
[DataField("swapModeSound")]
private SoundSpecifier _swapModeSound = new SoundPathSpecifier("/Audio/Items/genhit.ogg");
[DataField("successSound")]
private SoundSpecifier _successSound = new SoundPathSpecifier("/Audio/Items/deconstruct.ogg");
///Enum to store the different mode states for clarity.
private enum RcdMode
{
@@ -70,8 +77,8 @@ namespace Content.Server.RCD.Components
public void SwapMode(UseEntityEventArgs eventArgs)
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/genhit.ogg", Owner);
int mode = (int) _mode; //Firstly, cast our RCDmode mode to an int (enums are backed by ints anyway by default)
SoundSystem.Play(Filter.Pvs(Owner), _swapModeSound.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.
Owner.PopupMessage(eventArgs.User,
@@ -96,7 +103,7 @@ namespace Content.Server.RCD.Components
}
}
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
async Task<bool> 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())
@@ -155,7 +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!
}
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Items/deconstruct.ogg", Owner);
SoundSystem.Play(Filter.Pvs(Owner), _successSound.GetSound(), Owner);
_ammo--;
return true;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -2,6 +2,7 @@ using System;
using System.Threading;
using Content.Server.Access.Components;
using Content.Server.Power.Components;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -34,7 +35,7 @@ namespace Content.Server.Singularity.Components
[ViewVariables] public int FireShotCounter;
[ViewVariables] [DataField("fireSound")] public string FireSound = "/Audio/Weapons/emitter.ogg";
[ViewVariables] [DataField("fireSound")] public SoundSpecifier FireSound = new SoundPathSpecifier("/Audio/Weapons/emitter.ogg");
[ViewVariables] [DataField("boltType")] public string BoltType = "EmitterBolt";
[ViewVariables] [DataField("powerUseActive")] public int PowerUseActive = 500;
[ViewVariables] [DataField("fireBurstSize")] public int FireBurstSize = 3;

View File

@@ -1,5 +1,6 @@
using Content.Shared.Singularity;
using Content.Shared.Singularity.Components;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
@@ -7,6 +8,7 @@ using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -68,6 +70,10 @@ namespace Content.Server.Singularity.Components
private IPlayingAudioStream? _playingSound;
[DataField("singularityFormingSound")] private SoundSpecifier _singularityFormingSound = new SoundPathSpecifier("/Audio/Effects/singularity_form.ogg");
[DataField("singularitySound")] private SoundSpecifier _singularitySound = new SoundPathSpecifier("/Audio/Effects/singularity.ogg");
[DataField("singularityCollapsingSound")] private SoundSpecifier _singularityCollapsingSound = new SoundPathSpecifier("/Audio/Effects/singularity_collapse.ogg");
public override ComponentState GetComponentState(ICommonSession player)
{
return new SingularityComponentState(Level);
@@ -83,8 +89,8 @@ namespace Content.Server.Singularity.Components
audioParams.Loop = true;
audioParams.MaxDistance = 20f;
audioParams.Volume = 5;
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_form.ogg", Owner);
Timer.Spawn(5200,() => _playingSound = SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity.ogg", 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);
}
@@ -97,7 +103,7 @@ namespace Content.Server.Singularity.Components
protected override void OnRemove()
{
_playingSound?.Stop();
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates);
SoundSystem.Play(Filter.Pvs(Owner), _singularityCollapsingSound.GetSound(), Owner.Transform.Coordinates);
base.OnRemove();
}
}

View File

@@ -222,7 +222,7 @@ namespace Content.Server.Singularity.EntitySystems
// TODO: Move to projectile's code.
Timer.Spawn(3000, () => projectile.Delete());
SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound, component.Owner,
SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound.GetSound(), component.Owner,
AudioHelpers.WithVariation(EmitterComponent.Variation).WithVolume(EmitterComponent.Volume).WithMaxDistance(EmitterComponent.Distance));
}

View File

@@ -9,10 +9,7 @@ namespace Content.Server.Slippery
{
protected override void PlaySound(SlipperyComponent component)
{
if (!string.IsNullOrEmpty(component.SlipSound))
{
SoundSystem.Play(Filter.Pvs(component.Owner), component.SlipSound, component.Owner, AudioHelpers.WithVariation(0.2f));
}
SoundSystem.Play(Filter.Pvs(component.Owner), component.SlipSound.GetSound(), component.Owner, AudioHelpers.WithVariation(0.2f));
}
}
}

View File

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

View File

@@ -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 (!string.IsNullOrWhiteSpace(component.Sound.GetSound()))
{
SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), 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));
}
}
}

View File

@@ -1,11 +1,13 @@
using System.Linq;
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Sound;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
using System.Linq;
namespace Content.Server.Storage.Components
{
@@ -15,10 +17,13 @@ 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";
[DataField("cursedSound")] private SoundSpecifier _cursedSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
[DataField("cursedLockerSound")] private SoundSpecifier _cursedLockerSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
protected override void CloseStorage()
{
base.CloseStorage();
@@ -37,7 +42,7 @@ namespace Content.Server.Storage.Components
var locker = lockerEnt.GetComponent<EntityStorageComponent>();
if(locker.Open)
if (locker.Open)
locker.TryCloseStorage(Owner);
foreach (var entity in Contents.ContainedEntities.ToArray())
@@ -46,8 +51,8 @@ namespace Content.Server.Storage.Components
locker.Insert(entity);
}
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Effects/teleport_departure.ogg", Owner, AudioHelpers.WithVariation(0.125f));
SoundSystem.Play(Filter.Pvs(lockerEnt), "/Audio/Effects/teleport_arrival.ogg", 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));
}
}
}

View File

@@ -13,6 +13,7 @@ using Content.Shared.Item;
using Content.Shared.Movement;
using Content.Shared.Notification.Managers;
using Content.Shared.Physics;
using Content.Shared.Sound;
using Content.Shared.Storage;
using Content.Shared.Tool;
using Content.Shared.Verbs;
@@ -74,10 +75,10 @@ namespace Content.Server.Storage.Components
private bool _isWeldedShut;
[DataField("closeSound")]
private string _closeSound = "/Audio/Machines/closetclose.ogg";
private SoundSpecifier _closeSound = new SoundPathSpecifier("/Audio/Machines/closetclose.ogg");
[DataField("openSound")]
private string _openSound = "/Audio/Machines/closetopen.ogg";
private SoundSpecifier _openSound = new SoundPathSpecifier("/Audio/Machines/closetopen.ogg");
[ViewVariables]
protected Container Contents = default!;
@@ -225,7 +226,7 @@ namespace Content.Server.Storage.Components
}
ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _closeSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), _closeSound.GetSound(), Owner);
_lastInternalOpenAttempt = default;
}
@@ -234,7 +235,7 @@ namespace Content.Server.Storage.Components
Open = true;
EmptyContents();
ModifyComponents();
SoundSystem.Play(Filter.Pvs(Owner), _openSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), _openSound.GetSound(), Owner);
}
private void UpdateAppearance()

View File

@@ -8,12 +8,11 @@ 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;
using Content.Shared.Whitelist;
using Robust.Server.GameObjects;
@@ -65,7 +64,7 @@ namespace Content.Server.Storage.Components
public readonly HashSet<IPlayerSession> SubscribedSessions = new();
[DataField("storageSoundCollection")]
public string? StorageSoundCollection { get; set; }
public SoundSpecifier StorageSoundCollection { get; set; } = new SoundCollectionSpecifier("storageRustle");
[ViewVariables]
public override IReadOnlyList<IEntity>? StoredEntities => _storage?.ContainedEntities;
@@ -161,7 +160,7 @@ namespace Content.Server.Storage.Components
return;
}
PlaySoundCollection(StorageSoundCollection);
PlaySoundCollection();
EnsureInitialCalculated();
Logger.DebugS(LoggerName, $"Storage (UID {Owner.Uid}) had entity (UID {message.Entity.Uid}) inserted into it.");
@@ -257,7 +256,7 @@ namespace Content.Server.Storage.Components
/// <param name="entity">The entity to open the UI for</param>
public void OpenStorageUI(IEntity entity)
{
PlaySoundCollection(StorageSoundCollection);
PlaySoundCollection();
EnsureInitialCalculated();
var userSession = entity.GetComponent<ActorComponent>().PlayerSession;
@@ -402,8 +401,7 @@ namespace Content.Server.Storage.Components
var playerTransform = player.Transform;
if (!playerTransform.Coordinates.InRange(Owner.EntityManager, ownerTransform.Coordinates, 2) ||
!ownerTransform.IsMapTransform &&
!playerTransform.ContainsEntity(ownerTransform))
!ownerTransform.IsMapTransform && !playerTransform.ContainsEntity(ownerTransform))
{
break;
}
@@ -416,8 +414,7 @@ namespace Content.Server.Storage.Components
}
var item = entity.GetComponent<ItemComponent>();
if (item == null ||
!player.TryGetComponent(out HandsComponent? hands))
if (item == null || !player.TryGetComponent(out HandsComponent? hands))
{
break;
}
@@ -510,7 +507,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<SharedItemComponent>()))
if (_areaInsert && (eventArgs.Target == null || !eventArgs.Target.HasComponent<SharedItemComponent>()))
{
var validStorables = new List<IEntity>();
foreach (var entity in IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(eventArgs.ClickLocation, 1))
@@ -555,9 +552,9 @@ 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(StorageSoundCollection);
PlaySoundCollection();
SendNetworkMessage(
new AnimateInsertingEntitiesMessage(
successfullyInserted,
@@ -568,7 +565,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
@@ -576,7 +573,7 @@ namespace Content.Server.Storage.Components
|| !eventArgs.Target.HasComponent<SharedItemComponent>())
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<EntityUid>() { eventArgs.Target.Uid },
@@ -628,15 +625,9 @@ namespace Content.Server.Storage.Components
}
}
protected void PlaySoundCollection(string? name)
private void PlaySoundCollection()
{
if (string.IsNullOrEmpty(name))
{
return;
}
var file = AudioHelpers.GetRandomFileFromSoundCollection(name);
SoundSystem.Play(Filter.Pvs(Owner), file, Owner, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default);
}
}
}

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