2022-05-08 08:23:08 -05:00
using Robust.Shared.Audio ;
2022-12-28 04:03:25 +11:00
using Robust.Shared.GameStates ;
2023-09-28 16:20:29 -07:00
using Robust.Shared.Prototypes ;
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.)
2023-08-15 13:03:05 -07:00
/// Contains the option to let entities make noise when speaking, change speech verbs, datafields for the sounds in question, and relevant AudioParams.
2021-02-05 17:01:54 +01:00
/// </summary>
2023-09-28 16:20:29 -07:00
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
2023-08-22 18:14:33 -07:00
public sealed partial class SpeechComponent : Component
2021-02-05 17:01:54 +01:00
{
2023-09-28 16:20:29 -07:00
[DataField, AutoNetworkedField]
[Access(typeof(SpeechSystem), Friend = AccessPermissions.ReadWrite, Other = AccessPermissions.Read)]
2022-12-28 04:03:25 +11:00
public bool Enabled = true ;
2021-03-05 01:08:38 +01:00
2022-05-08 08:23:08 -05:00
[ViewVariables(VVAccess.ReadWrite)]
2023-09-28 16:20:29 -07:00
[DataField]
public ProtoId < SpeechSoundsPrototype > ? SpeechSounds ;
2022-05-08 08:23:08 -05:00
2023-08-15 13:03:05 -07:00
/// <summary>
/// What speech verb prototype should be used by default for displaying this entity's messages?
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
2023-09-28 16:20:29 -07:00
[DataField]
public ProtoId < SpeechVerbPrototype > SpeechVerb = "Default" ;
2023-08-15 13:03:05 -07:00
/// <summary>
/// A mapping from chat suffixes loc strings to speech verb prototypes that should be conditionally used.
/// For things like '?' changing to 'asks' or '!!' making text bold and changing to 'yells'. Can be overridden if necessary.
/// </summary>
2023-09-28 16:20:29 -07:00
[DataField]
public Dictionary < string , ProtoId < SpeechVerbPrototype > > SuffixSpeechVerbs = new ( )
2023-08-15 13:03:05 -07:00
{
{ "chat-speech-verb-suffix-exclamation-strong" , "DefaultExclamationStrong" } ,
{ "chat-speech-verb-suffix-exclamation" , "DefaultExclamation" } ,
{ "chat-speech-verb-suffix-question" , "DefaultQuestion" } ,
2023-08-31 22:15:31 -05:00
{ "chat-speech-verb-suffix-stutter" , "DefaultStutter" } ,
{ "chat-speech-verb-suffix-mumble" , "DefaultMumble" } ,
2023-08-15 13:03:05 -07:00
} ;
2023-09-28 16:20:29 -07:00
[DataField]
2024-01-28 03:49:55 -07:00
public AudioParams AudioParams = AudioParams . Default . WithVolume ( - 2f ) . WithRolloffFactor ( 4.5f ) ;
2022-05-08 08:23:08 -05:00
[ViewVariables(VVAccess.ReadWrite)]
2023-09-28 16:20:29 -07:00
[DataField]
2022-05-08 08:23:08 -05:00
public float SoundCooldownTime { get ; set ; } = 0.5f ;
public TimeSpan LastTimeSoundPlayed = TimeSpan . Zero ;
2021-02-05 17:01:54 +01:00
}
}