From 8f97989582c18de207b60c6473816db37b114b83 Mon Sep 17 00:00:00 2001 From: ps3moira <113228053+ps3moira@users.noreply.github.com> Date: Thu, 28 Dec 2023 05:03:15 -0800 Subject: [PATCH] Add Accent Component and Accent System --- .../Components/ScottishAccentComponent.cs | 6 ++++ .../EntitySystems/ScottishAccentSystem.cs | 31 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs create mode 100644 Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs diff --git a/Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs b/Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs new file mode 100644 index 00000000000..90d21ea05e1 --- /dev/null +++ b/Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs @@ -0,0 +1,6 @@ +[RegisterComponent] +[Access(typeof(ScottishAccentSystem))] +public sealed partial class ScottishAccentComponent : Component +{ + +} \ No newline at end of file diff --git a/Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs b/Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs new file mode 100644 index 00000000000..6d816e2188d --- /dev/null +++ b/Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs @@ -0,0 +1,31 @@ +using Content.Server.Speech.Components; +using Robust.Shared.Random; +using System.Text.RegularExpressions; + +namespace Content.Server.Speech.EntitySystems; + +public sealed class ScottishAccentSystem : EntitySystem +{ + [Dependency] private readonly ReplacementAccentSystem _replacement = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAccentGet); + } + + // converts left word when typed into the right word. For example typing you becomes ye. + public string Accentuate(string message, ScottishAccentComponent component) + { + var msg = message; + + msg = _replacement.ApplyReplacements(msg, "Scottish"); + return msg; + } + + private void OnAccentGet(EntityUid uid, ScottishAccentComponent component, AccentGetEvent args) + { + args.Message = Accentuate(args.Message, component); + } +}