1
0

OwOAccentSystem.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Speech.Components;
  2. using Robust.Shared.Random;
  3. namespace Content.Server.Speech.EntitySystems
  4. {
  5. public sealed class OwOAccentSystem : EntitySystem
  6. {
  7. [Dependency] private readonly IRobustRandom _random = default!;
  8. private static readonly IReadOnlyList<string> Faces = new List<string>{
  9. " (•`ω´•)", " ;;w;;", " owo", " UwU", " >w<", " ^w^"
  10. }.AsReadOnly();
  11. private static readonly IReadOnlyDictionary<string, string> SpecialWords = new Dictionary<string, string>()
  12. {
  13. { "you", "wu" },
  14. };
  15. public override void Initialize()
  16. {
  17. SubscribeLocalEvent<OwOAccentComponent, AccentGetEvent>(OnAccent);
  18. }
  19. public string Accentuate(string message)
  20. {
  21. foreach (var (word, repl) in SpecialWords)
  22. {
  23. message = message.Replace(word, repl);
  24. }
  25. return message.Replace("!", _random.Pick(Faces))
  26. .Replace("r", "w").Replace("R", "W")
  27. .Replace("l", "w").Replace("L", "W");
  28. }
  29. private void OnAccent(EntityUid uid, OwOAccentComponent component, AccentGetEvent args)
  30. {
  31. args.Message = Accentuate(args.Message);
  32. }
  33. }
  34. }