CatStation/Content.Shared/Speech/EntitySystems/OwOAccentSystem.cs
2026-07-30 05:24:08 +07:00

47 lines
1.5 KiB
C#
Raw Permalink 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.Collections.Frozen;
using Content.Shared.Random.Helpers;
using Content.Shared.Speech.Components;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Shared.Speech.EntitySystems;
public sealed partial class OwOAccentSystem : RelayAccentSystem<OwOAccentComponent>
{
[Dependency] private IGameTiming _timing = default!;
[Dependency] private IRobustRandom _random = default!;
private static readonly IReadOnlyList<string> Faces =
[
" (•`ω´•)", " ;;w;;", " owo", " UwU", " >w<", " ^w^",
];
private static readonly FrozenDictionary<string, string> SpecialWords =
new Dictionary<string, string>
{
{ "you", "wu" },
{ "ты", "ти" }, // Corvax-Localization
}.ToFrozenDictionary();
public override string Accentuate(string message, Entity<OwOAccentComponent>? ent = null)
{
var random = ent.HasValue
? SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(ent.Value))
: _random;
foreach (var (word, repl) in SpecialWords)
{
message = message.Replace(word, repl);
}
return message.Replace("!", random.Pick(Faces))
.Replace("r", "w")
.Replace("R", "W")
.Replace("l", "w")
.Replace("L", "W")
// Corvax-Localization-Start
.Replace("р", "в").Replace("Р", "В")
.Replace("л", "в").Replace("Л", "В");
// Corvax-Localization-End
}
}