2023-05-24 17:41:22 +06:00
|
|
|
using Content.Server.Speech;
|
2024-01-17 12:48:23 +03:00
|
|
|
using Robust.Server.Audio;
|
2023-05-24 17:41:22 +06:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Player;
|
|
|
|
|
|
2024-01-28 18:18:54 +07:00
|
|
|
namespace Content.Server._White.Other.Speech;
|
2023-05-24 17:41:22 +06:00
|
|
|
|
|
|
|
|
public sealed class VoiceOfGodSystem : EntitySystem
|
|
|
|
|
{
|
2024-01-17 12:48:23 +03:00
|
|
|
[Dependency] private readonly AudioSystem _audio = default!;
|
2023-05-24 17:41:22 +06:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<VoiceOfGodComponent, AccentGetEvent>(OnAccent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string Accentuate(VoiceOfGodComponent component, string message)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(component.Sound))
|
|
|
|
|
{
|
2024-01-17 12:48:23 +03:00
|
|
|
_audio.PlayPvs(component.Sound,
|
2023-05-24 17:41:22 +06:00
|
|
|
component.Owner,
|
|
|
|
|
new AudioParams()
|
|
|
|
|
{
|
|
|
|
|
Volume = component.Volume
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return component.Accent ? message.ToUpper() : message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAccent(EntityUid uid, VoiceOfGodComponent component, AccentGetEvent args)
|
|
|
|
|
{
|
|
|
|
|
args.Message = Accentuate(component, args.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|