mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
43 lines
2 KiB
C#
43 lines
2 KiB
C#
using System.Text.RegularExpressions;
|
||
using Content.Shared.Speech.Components;
|
||
using Content.Shared.Speech.EntitySystems;
|
||
using Robust.Shared.Random;
|
||
|
||
namespace Content.Shared.Speech.EntitySystems;
|
||
|
||
public sealed partial class MothAccentSystem : RelayAccentSystem<MothAccentComponent>
|
||
{
|
||
[Dependency] private IRobustRandom _random = default!; // Corvax-Localization
|
||
|
||
private static readonly Regex RegexLowerBuzz = new("z{1,3}");
|
||
private static readonly Regex RegexUpperBuzz = new("Z{1,3}");
|
||
|
||
// Corvax-Localization-Start
|
||
private static readonly Regex _regexLowerZh = new Regex("ж+");
|
||
private static readonly Regex _regexUpperZh = new Regex("Ж+");
|
||
private static readonly Regex _regexLowerZ = new Regex("з+");
|
||
private static readonly Regex _regexUpperZ = new Regex("З+");
|
||
|
||
private static readonly List<string> _replacementsZh = new List<string> { "жж", "жжж" };
|
||
private static readonly List<string> _replacementsZhUpper = new List<string> { "ЖЖ", "ЖЖЖ" };
|
||
private static readonly List<string> _replacementsZ = new List<string> { "зз", "ззз" };
|
||
private static readonly List<string> _replacementsZUpper = new List<string> { "ЗЗ", "ЗЗЗ" };
|
||
// Corvax-Localization-End
|
||
|
||
public override string Accentuate(string message, Entity<MothAccentComponent>? ent = null)
|
||
{
|
||
// buzzz
|
||
message = RegexLowerBuzz.Replace(message, "zzz");
|
||
// buZZZ
|
||
message = RegexUpperBuzz.Replace(message, "ZZZ");
|
||
|
||
// Corvax-Localization-Start
|
||
message = _regexLowerZh.Replace(message, _random.Pick(_replacementsZh));
|
||
message = _regexUpperZh.Replace(message, _random.Pick(_replacementsZhUpper));
|
||
message = _regexLowerZ.Replace(message, _random.Pick(_replacementsZ)); // используем существующий regexLowerZ
|
||
message = _regexUpperZ.Replace(message, _random.Pick(_replacementsZUpper)); // используем существующий regexUpperZ
|
||
// Corvax-Localization-End
|
||
|
||
return message;
|
||
}
|
||
}
|