Files
tbd-station-14/Content.Server/Speech/EntitySystems/OwOAccentSystem.cs
Princess Cheeseballs 367ff79006 Accents Event to Shared (#38948)
* 27 file diff

* 27 file diff 2

* Apply suggestions from code review

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
2025-07-12 22:52:51 +02:00

43 lines
1.3 KiB
C#

using Content.Server.Speech.Components;
using Content.Shared.Speech;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems
{
public sealed class OwOAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
private static readonly IReadOnlyList<string> Faces = new List<string>{
" (•`ω´•)", " ;;w;;", " owo", " UwU", " >w<", " ^w^"
}.AsReadOnly();
private static readonly IReadOnlyDictionary<string, string> SpecialWords = new Dictionary<string, string>()
{
{ "you", "wu" },
};
public override void Initialize()
{
SubscribeLocalEvent<OwOAccentComponent, AccentGetEvent>(OnAccent);
}
public string Accentuate(string message)
{
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");
}
private void OnAccent(EntityUid uid, OwOAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}
}