replacing sound (collection) names with SoundSpecifier - part 1

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

View File

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

View File

@@ -24,6 +24,7 @@ using Content.Shared.Kitchen.Components;
using Content.Shared.Notification;
using Content.Shared.Notification.Managers;
using Content.Shared.Power;
using Content.Shared.Sound;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -50,12 +51,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;
@@ -335,7 +338,8 @@ namespace Content.Server.Kitchen.Components
}
SetAppearance(MicrowaveVisualState.Cooking);
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound, Owner, AudioParams.Default);
if(_startCookingSound.TryGetSound(out var startCookingSound))
SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default);
Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() =>
{
if (_lostPower)
@@ -362,7 +366,9 @@ namespace Content.Server.Kitchen.Components
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound))
SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
SetAppearance(MicrowaveVisualState.Idle);
_busy = false;
@@ -495,7 +501,8 @@ namespace Content.Server.Kitchen.Components
private void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), "/Audio/Machines/machine_switch.ogg",Owner,AudioParams.Default.WithVolume(-2f));
if(_clickSound.TryGetSound(out var clickSound))
SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f));
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

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