mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using Content.Server.Speech.Components;
|
||
using Content.Shared.Speech;
|
||
using Content.Shared.StatusEffectNew;
|
||
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" },
|
||
{ "ты", "ти" }, // Corvax-Localization
|
||
};
|
||
|
||
public override void Initialize()
|
||
{
|
||
SubscribeLocalEvent<OwOAccentComponent, AccentGetEvent>(OnAccent);
|
||
SubscribeLocalEvent<OwOAccentComponent, StatusEffectRelayedEvent<AccentGetEvent>>(OnAccentRelayed);
|
||
}
|
||
|
||
public string Accentuate(string message)
|
||
{
|
||
foreach (var (word, repl) in SpecialWords)
|
||
{
|
||
message = message.Replace(word, repl);
|
||
}
|
||
|
||
return message.Replace("!", _random.Pick(Faces))
|
||
// Corvax-Localization-Start
|
||
.Replace("р", "в").Replace("Р", "В")
|
||
.Replace("л", "в").Replace("Л", "В")
|
||
// Corvax-Localization-End
|
||
.Replace("r", "w").Replace("R", "W")
|
||
.Replace("l", "w").Replace("L", "W");
|
||
}
|
||
|
||
private void OnAccent(Entity<OwOAccentComponent> entity, ref AccentGetEvent args)
|
||
{
|
||
args.Message = Accentuate(args.Message);
|
||
}
|
||
|
||
private void OnAccentRelayed(Entity<OwOAccentComponent> entity, ref StatusEffectRelayedEvent<AccentGetEvent> args)
|
||
{
|
||
args.Args.Message = Accentuate(args.Args.Message);
|
||
}
|
||
|
||
}
|
||
}
|