Files
OldThink/Content.Server/SurveillanceCamera/Systems/SurveillanceCameraSpeakerSystem.cs
RedBurningPhoenix 3ed0f2c4bb SUPER CAMERA(OCHKO) (#501)
* SUPER CAMERA(OCHKO)

* Удобный монитор камер и портативный мониторинг для детектива. (#25)

* Улучшение мониторинга камер

* Портативный монитор камер для дека

* чейнжлог

* Revert "Удобный монитор камер и портативный мониторинг для детектива. (#25)"

This reverts commit adf35bb8f6ddd6256b18841a81b330224ebff103.

* Revert "Revert "Удобный монитор камер и портативный мониторинг для детектива. (#25)""

This reverts commit bd30fe45046b7b8508e8277f8c186d03338354cd.

* cleanups

* its so over

---------

Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com>
Co-authored-by: drdth <drdtheuser@gmail.com>
2024-07-27 18:47:27 +03:00

57 lines
2.1 KiB
C#

using Content.Server.Chat.Systems;
using Content.Server.Speech;
using Content.Shared.Speech;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
namespace Content.Server.SurveillanceCamera.Systems;
/// <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);
}
}