2022-05-08 08:23:08 -05:00
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype ;
using Robust.Shared.Audio ;
2021-02-05 17:01:54 +01:00
2021-06-09 22:19:39 +02:00
namespace Content.Shared.Speech
2021-02-05 17:01:54 +01:00
{
/// <summary>
2022-05-08 08:23:08 -05:00
/// Component required for entities to be able to speak. (TODO: Entities can speak fine without this, this only forbids them speak if they have it and enabled is false.)
/// Contains the option to let entities make noise when speaking, datafields for the sounds in question, and relevant AudioParams.
2021-02-05 17:01:54 +01:00
/// </summary>
[RegisterComponent]
2022-02-16 00:23:23 -07:00
public sealed class SharedSpeechComponent : Component
2021-02-05 17:01:54 +01:00
{
2021-03-05 01:08:38 +01:00
[DataField("enabled")]
private bool _enabled = true ;
2022-05-08 08:23:08 -05:00
[ViewVariables(VVAccess.ReadWrite)]
2022-05-08 23:39:51 +10:00
[DataField("speechSounds", customTypeSerializer:typeof(PrototypeIdSerializer<SpeechSoundsPrototype>))]
public string? SpeechSounds ;
2022-05-08 08:23:08 -05:00
[DataField("audioParams")]
2022-05-08 23:55:23 -05:00
public AudioParams AudioParams = AudioParams . Default . WithVolume ( 6f ) . WithRolloffFactor ( 4.5f ) ;
2022-05-08 08:23:08 -05:00
[ViewVariables(VVAccess.ReadWrite)]
[DataField("soundCooldownTime")]
public float SoundCooldownTime { get ; set ; } = 0.5f ;
public TimeSpan LastTimeSoundPlayed = TimeSpan . Zero ;
2021-02-05 17:01:54 +01:00
public bool Enabled
{
get = > _enabled ;
set
{
if ( _enabled = = value ) return ;
_enabled = value ;
Dirty ( ) ;
}
}
}
}