Files
OldThink/Content.Server/Speech/EntitySystems/MothAccentSystem.cs
2025-01-11 23:59:36 +03:00

58 lines
1.6 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 MothAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!; // WD
private static readonly Regex RegexLowerBuzz = new Regex("z{1,3}");
private static readonly Regex RegexUpperBuzz = new Regex("Z{1,3}");
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MothAccentComponent, AccentGetEvent>(OnAccent);
}
private void OnAccent(EntityUid uid, MothAccentComponent component, AccentGetEvent args)
{
var message = args.Message;
// buzzz
message = RegexLowerBuzz.Replace(message, "zzz");
// buZZZ
message = RegexUpperBuzz.Replace(message, "ZZZ");
// WD EDIT START
// ж => жжж
message = Regex.Replace(
message,
"ж+",
_random.Pick(new List<string>() { "жж", "жжж" })
);
// Ж => ЖЖЖ
message = Regex.Replace(
message,
"Ж+",
_random.Pick(new List<string>() { "ЖЖ", "ЖЖЖ" })
);
// з => ззз
message = Regex.Replace(
message,
"з+",
_random.Pick(new List<string>() { "зз", "ззз" })
);
// З => ЗЗЗ
message = Regex.Replace(
message,
"З+",
_random.Pick(new List<string>() { "ЗЗ", "ЗЗЗ" })
);
// WD EDIT END
args.Message = message;
}
}