diff --git a/Content.Server/Speech/Components/RussianAccentComponent.cs b/Content.Server/Speech/Components/RussianAccentComponent.cs new file mode 100644 index 0000000000..fdf644cd94 --- /dev/null +++ b/Content.Server/Speech/Components/RussianAccentComponent.cs @@ -0,0 +1,7 @@ +using Robust.Shared.GameObjects; + +namespace Content.Server.Speech.Components; + +[RegisterComponent] +[ComponentProtoName("RussianAccent")] +public sealed class RussianAccentComponent : Component {} diff --git a/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs b/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs new file mode 100644 index 0000000000..0d7f4cb765 --- /dev/null +++ b/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs @@ -0,0 +1,50 @@ +using System.Text; +using Content.Server.Speech.Components; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; +using Robust.Shared.Random; + +namespace Content.Server.Speech.EntitySystems; + +public sealed class RussianAccentSystem : EntitySystem +{ + public override void Initialize() + { + SubscribeLocalEvent(OnAccent); + } + + public static string Accentuate(string message) + { + var accentedMessage = new StringBuilder(message); + + for (var i = 0; i < accentedMessage.Length; i++) + { + var c = accentedMessage[i]; + + accentedMessage[i] = c switch + { + 'b' => 'в', + 'N' => 'И', + 'n' => 'и', + 'K' => 'К', + 'k' => 'к', + 'm' => 'м', + 'h' => 'н', + 't' => 'т', + 'R' => 'Я', + 'r' => 'я', + 'Y' => 'У', + 'W' => 'Ш', + 'w' => 'ш', + _ => accentedMessage[i] + }; + } + + return accentedMessage.ToString(); + } + + private void OnAccent(EntityUid uid, RussianAccentComponent component, AccentGetEvent args) + { + args.Message = Accentuate(args.Message); + } +} diff --git a/Resources/Prototypes/Entities/Clothing/Head/hats.yml b/Resources/Prototypes/Entities/Clothing/Head/hats.yml index 376698ad35..084988bdbc 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hats.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hats.yml @@ -294,6 +294,8 @@ sprite: Clothing/Head/Hats/ushanka.rsi - type: Clothing sprite: Clothing/Head/Hats/ushanka.rsi + - type: AddAccentClothing + accent: RussianAccent - type: entity parent: ClothingHeadBase