Adds a semitone shifting AudioHelper (#2608)
* Add semitone audio helper * use semitone audio helper on bike horn * prettify * clamp this instead * Expose these to viewvars
This commit is contained in:
@@ -5,6 +5,7 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Sound
|
||||
{
|
||||
@@ -18,14 +19,16 @@ namespace Content.Server.GameObjects.Components.Sound
|
||||
///
|
||||
public override string Name => "EmitSoundOnUse";
|
||||
|
||||
public string _soundName;
|
||||
public float _pitchVariation;
|
||||
[ViewVariables(VVAccess.ReadWrite)] public string _soundName;
|
||||
[ViewVariables(VVAccess.ReadWrite)] public float _pitchVariation;
|
||||
[ViewVariables(VVAccess.ReadWrite)] public int _semitoneVariation;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _soundName, "sound", string.Empty);
|
||||
serializer.DataField(ref _pitchVariation, "variation", 0.0f);
|
||||
serializer.DataField(ref _semitoneVariation, "semitoneVariation", 0);
|
||||
}
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
@@ -37,6 +40,11 @@ namespace Content.Server.GameObjects.Components.Sound
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_soundName, Owner, AudioHelpers.WithVariation(_pitchVariation).WithVolume(-2f));
|
||||
return true;
|
||||
}
|
||||
if (_semitoneVariation > 0)
|
||||
{
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_soundName, Owner, AudioHelpers.WithSemitoneVariation(_semitoneVariation).WithVolume(-2f));
|
||||
return true;
|
||||
}
|
||||
EntitySystem.Get<AudioSystem>().PlayFromEntity(_soundName, Owner, AudioParams.Default.WithVolume(-2f));
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user