Files
OldThink/Content.Server/Speech/EntitySystems/BarkAccentSystem.cs
Aviu00 9f00a90f24 Aspects (#266)
* - add: Revive fast and furious aspect.

* - add: Update accents.

* - add: More buzzing for moth.

* - tweak: Change desc.

* - fix: Fixes.

* - add: RandomItemAspect.

* - fix: Fix arachnid socks.

* - tweak: Update desc part 2.
2024-04-02 17:19:33 +03:00

51 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Text.RegularExpressions;
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>{
" Гав!", " ГАВ", " гав-гав" // WD EDIT
}.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);
}
// WD EDIT START
message = Regex.Replace(message, "р{1,3}", "ррр");
message = Regex.Replace(message, "Р{1,3}", "РРР");
// WD EDIT END
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);
}
}
}