removed TryGetSound + made some SoundSpecifier datafields required

This commit is contained in:
Galactic Chimp
2021-07-31 19:52:33 +02:00
parent 8ff703c338
commit 57016d14b4
114 changed files with 519 additions and 785 deletions

View File

@@ -420,8 +420,7 @@ namespace Content.Server.Chemistry.Components
private void ClickSound()
{
if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
[Verb]

View File

@@ -72,8 +72,7 @@ namespace Content.Server.Chemistry.Components
meleeSys.SendLunge(angle, user);
}
if(_injectSound.TryGetSound(out var injectSound))
SoundSystem.Play(Filter.Pvs(user), injectSound, user);
SoundSystem.Play(Filter.Pvs(user), _injectSound.GetSound(), user);
var targetSolution = target.GetComponent<SolutionContainerComponent>();

View File

@@ -23,7 +23,7 @@ namespace Content.Server.Chemistry.Components
public override string Name => "Pill";
[ViewVariables]
[DataField("useSound")]
[DataField("useSound", required: true)]
protected override SoundSpecifier UseSound { get; set; } = default!;
[ViewVariables]
@@ -99,10 +99,7 @@ namespace Content.Server.Chemistry.Components
firstStomach.TryTransferSolution(split);
if (UseSound.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(trueTarget), sound, trueTarget, AudioParams.Default.WithVolume(-1f));
}
SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f));
trueTarget.PopupMessage(user, Loc.GetString("pill-component-swallow-success-message"));

View File

@@ -47,7 +47,8 @@ namespace Content.Server.Chemistry.Components
[ViewVariables] private ContainerSlot _beakerContainer = default!;
[ViewVariables] [DataField("pack")] private string _packPrototypeId = "";
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("clickSound")]
private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null;
[ViewVariables] private ReagentUnit _dispenseAmount = ReagentUnit.New(10);
@@ -361,8 +362,7 @@ namespace Content.Server.Chemistry.Components
private void ClickSound()
{
if(_clickSound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
[Verb]

View File

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

View File

@@ -80,7 +80,7 @@ namespace Content.Server.Chemistry.ReactionEffects
/// <summary>
/// Sound that will get played when this reaction effect occurs.
/// </summary>
[DataField("sound")] private SoundSpecifier _sound = default!;
[DataField("sound", required: true)] private SoundSpecifier _sound = default!;
protected AreaReactionEffect()
{
@@ -136,10 +136,7 @@ namespace Content.Server.Chemistry.ReactionEffects
areaEffectComponent.TryAddSolution(solution);
areaEffectComponent.Start(amount, _duration, _spreadDelay, _removeDelay);
if (_sound.TryGetSound(out var sound))
{
SoundSystem.Play(Filter.Pvs(solutionEntity), sound, solutionEntity, AudioHelpers.WithVariation(0.125f));
}
SoundSystem.Play(Filter.Pvs(solutionEntity), _sound.GetSound(), solutionEntity, AudioHelpers.WithVariation(0.125f));
}
protected abstract SolutionAreaEffectComponent? GetAreaEffectComponent(IEntity entity);