Various Entities make sounds when speaking (#7980)

* Speech Sounds from Goonstation

* Added some speech sound prototypes for humans, mice, and vending machines. More to come later?

* Custom synthesized sound for a vending machine ad

* Gave mice and vending machines Speech Components on their base prototypes to make sounds

* Humans now talk using the 'Alto' voice. In the future this can be changed in customization screen

* New Prototype 'SpeechSounds' with three soundspecifiers for saying sound, asking sound, exclaiming sound.

* SharedSpeechComponent modified from being useless to being responsible for making speech noises.

* Initial creation of SpeechNoiseSystem for making Sounds when certain entities speak.

* whitespace fix

* License fix

* Remove leftover using from debugging

* Added a cooldown editable in yaml

* SharedSpeechComponent has the proper cooldown now. oops
This commit is contained in:
hubismal
2022-05-08 08:23:08 -05:00
committed by GitHub
parent 41a74b8c2a
commit 304e9b824e
21 changed files with 219 additions and 3 deletions

View File

@@ -1,10 +1,18 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Audio;
using Content.Shared.Sound;
using Content.Shared.Speech;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using System;
namespace Content.Shared.Speech
{
/// <summary>
/// Component required for entities to be able to speak.
/// 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.
/// </summary>
[RegisterComponent]
public sealed class SharedSpeechComponent : Component
@@ -12,6 +20,29 @@ namespace Content.Shared.Speech
[DataField("enabled")]
private bool _enabled = true;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("playSpeechSound")]
public bool PlaySpeechSound = false;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("speechSoundsId", customTypeSerializer:typeof(PrototypeIdSerializer<SpeechSoundsPrototype>))]
public string SpeechSoundsId { get; set; } = "Alto";
[DataField("audioParams")]
public AudioParams AudioParams = AudioParams.Default.WithVolume(5f);
[ViewVariables(VVAccess.ReadWrite)]
[DataField("soundCooldownTime")]
public float SoundCooldownTime { get; set; } = 0.5f;
public TimeSpan LastTimeSoundPlayed = TimeSpan.Zero;
//Don't use this.
//Cache for SpeechSoundsPrototype to avoid Indexing every single time someone talks.
public SpeechSoundsPrototype? SpeechSoundsCache = null;
public bool Enabled
{
get => _enabled;