Files
OldThink/Content.Server/Speech/EntitySystems/LizardAccentSystem.cs
2024-01-10 19:53:13 +07:00

89 lines
2.4 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 LizardAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LizardAccentComponent, AccentGetEvent>(OnAccent);
}
private void OnAccent(EntityUid uid, LizardAccentComponent component, AccentGetEvent args)
{
var message = args.Message;
// hissss
message = Regex.Replace(message, "s+", "sss");
// hiSSS
message = Regex.Replace(message, "S+", "SSS");
// ekssit
message = Regex.Replace(message, @"(\w)x", "$1kss");
// ecks
message = Regex.Replace(message, @"\bx([\-|r|R]|\b)", "ecks$1");
// eckS
message = Regex.Replace(message, @"\bX([\-|r|R]|\b)", "ECKS$1");
//WD-EDIT
// c => ссс
message = Regex.Replace(
message,
"с+",
_random.Pick(new List<string>() { "сс", "ссс" })
);
// С => CCC
message = Regex.Replace(
message,
"С+",
_random.Pick(new List<string>() { "Сс", "Ссс" })
);
// з => ссс
message = Regex.Replace(
message,
"з+",
_random.Pick(new List<string>() { "сс", "ссс" })
);
// З => CCC
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>() { "щщ", "щщщ" })
);
// Ч => ЩЩЩ
message = Regex.Replace(
message,
"Ч+",
_random.Pick(new List<string>() { "Щщ", "Щщщ" })
);
//WD-EDIT
args.Message = message;
}
}