2024-04-02 23:19:33 +09:00
|
|
|
|
using System.Text.RegularExpressions;
|
2023-12-16 11:30:20 +03:00
|
|
|
|
using Content.Server.Speech.Components;
|
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Speech.EntitySystems
|
|
|
|
|
|
{
|
|
|
|
|
|
public sealed class BarkAccentSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly IReadOnlyList<string> Barks = new List<string>{
|
2024-04-02 23:19:33 +09:00
|
|
|
|
" Гав!", " ГАВ", " гав-гав" // WD EDIT
|
2023-12-16 11:30:20 +03:00
|
|
|
|
}.AsReadOnly();
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly IReadOnlyDictionary<string, string> SpecialWords = new Dictionary<string, string>()
|
|
|
|
|
|
{
|
|
|
|
|
|
{ "ah", "arf" },
|
|
|
|
|
|
{ "Ah", "Arf" },
|
|
|
|
|
|
{ "oh", "oof" },
|
|
|
|
|
|
{ "Oh", "Oof" },
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
SubscribeLocalEvent<BarkAccentComponent, AccentGetEvent>(OnAccent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string Accentuate(string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var (word, repl) in SpecialWords)
|
|
|
|
|
|
{
|
|
|
|
|
|
message = message.Replace(word, repl);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-02 23:19:33 +09:00
|
|
|
|
// WD EDIT START
|
|
|
|
|
|
message = Regex.Replace(message, "р{1,3}", "ррр");
|
|
|
|
|
|
|
|
|
|
|
|
message = Regex.Replace(message, "Р{1,3}", "РРР");
|
|
|
|
|
|
// WD EDIT END
|
|
|
|
|
|
|
2023-12-16 11:30:20 +03:00
|
|
|
|
return message.Replace("!", _random.Pick(Barks))
|
|
|
|
|
|
.Replace("l", "r").Replace("L", "R");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnAccent(EntityUid uid, BarkAccentComponent component, AccentGetEvent args)
|
|
|
|
|
|
{
|
|
|
|
|
|
args.Message = Accentuate(args.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|