Files
wwdpublic/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSpeakerSystem.cs
Mnemotechnican 92dcd724d4 Refactor Sign Languages and Language Markers (#575)
# Description
This refactors #510 and #553. #553 specifically was reverted and
re-implemented from scratch. As a consequence to all of this, the chat
system was refactored a bit too, hopefully for the best.

Changes:
- InGameICChatType, InGameOOCChatType, ChatTransmitRange were all moved
to shared and made serializable
- Added a method to wrap whisper messages to reduce code duplication in
chat system
- Both WrapPublicMethod and WrapWhisperMessage call the same generic
WrapMessage method, which allows to add speech verbs to whispers and
more. That method is also fully responsible for adding language markers
and deducing speech verbs now.
- Everything related to speech was moved out of LanguagePrototype and
into SpeechOverrideInfo. LanguagePrototype now holds an instance of
that.
- Added AllowRadio, RequireSpeech, ChatTypeOverride,
SpeechVerbOverrides, MessageWrapOverrides to SpeechOverrideInfo, all of
which are used in implementing the sign language.
- Suffered a lot

# TODO
- [X] Cry
- [X] Fix the sign language not displaying properly over the character.
- [X] Find a way to circumvent being unable to speak??

<details><summary><h1>Media</h1></summary><p>


![image](https://github.com/user-attachments/assets/845ec5d3-20aa-4786-bdc8-c39c80e0a4a3)

See below

</p></details>

# Changelog
No cl no fun

---------

Signed-off-by: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com>
Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
2024-07-26 13:11:42 -07:00

58 lines
2.1 KiB
C#

using Content.Server.Chat.Systems;
using Content.Server.Speech;
using Content.Shared.Chat;
using Content.Shared.Speech;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
namespace Content.Server.SurveillanceCamera;
/// <summary>
/// This handles speech for surveillance camera monitors.
/// </summary>
public sealed class SurveillanceCameraSpeakerSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly SpeechSoundSystem _speechSound = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<SurveillanceCameraSpeakerComponent, SurveillanceCameraSpeechSendEvent>(OnSpeechSent);
}
private void OnSpeechSent(EntityUid uid, SurveillanceCameraSpeakerComponent component,
SurveillanceCameraSpeechSendEvent args)
{
if (!component.SpeechEnabled)
{
return;
}
var time = _gameTiming.CurTime;
var cd = TimeSpan.FromSeconds(component.SpeechSoundCooldown);
// this part's mostly copied from speech
// what is wrong with you?
if (time - component.LastSoundPlayed < cd
&& TryComp<SpeechComponent>(args.Speaker, out var speech))
{
var sound = _speechSound.GetSpeechSound((args.Speaker, speech), args.Message);
_audioSystem.PlayPvs(sound, uid);
component.LastSoundPlayed = time;
}
var nameEv = new TransformSpeakerNameEvent(args.Speaker, Name(args.Speaker));
RaiseLocalEvent(args.Speaker, nameEv);
var name = Loc.GetString("speech-name-relay", ("speaker", Name(uid)),
("originalName", nameEv.Name));
// log to chat so people can identity the speaker/source, but avoid clogging ghost chat if there are many radios
_chatSystem.TrySendInGameICMessage(uid, args.Message, InGameICChatType.Speak, ChatTransmitRange.GhostRangeLimit, nameOverride: name);
}
}