From 7631b66c69631c8ca10259d9e50bb75fcf26fdaa Mon Sep 17 00:00:00 2001 From: dahnte <70238020+dahnte@users.noreply.github.com> Date: Tue, 19 Sep 2023 21:51:50 -0700 Subject: [PATCH] Added lisp as a character trait (#20350) --- .../Speech/Components/FrontalLispComponent.cs | 7 +++++ .../Speech/EntitySystems/FrontalLispSystem.cs | 30 +++++++++++++++++++ Resources/Locale/en-US/traits/traits.ftl | 3 ++ Resources/Prototypes/Traits/disabilities.yml | 7 +++++ 4 files changed, 47 insertions(+) create mode 100644 Content.Server/Speech/Components/FrontalLispComponent.cs create mode 100644 Content.Server/Speech/EntitySystems/FrontalLispSystem.cs diff --git a/Content.Server/Speech/Components/FrontalLispComponent.cs b/Content.Server/Speech/Components/FrontalLispComponent.cs new file mode 100644 index 0000000000..dbf1cccd33 --- /dev/null +++ b/Content.Server/Speech/Components/FrontalLispComponent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.Speech.Components; + +[RegisterComponent] +public sealed partial class FrontalLispComponent : Component +{ + +} diff --git a/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs b/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs new file mode 100644 index 0000000000..6ee548515c --- /dev/null +++ b/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs @@ -0,0 +1,30 @@ +using System.Text.RegularExpressions; +using Content.Server.Speech.Components; + +namespace Content.Server.Speech.EntitySystems; + +public sealed class FrontalLispSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnAccent); + } + + private void OnAccent(EntityUid uid, FrontalLispComponent component, AccentGetEvent args) + { + var message = args.Message; + + // handles ts, c(iey), z, ps, ti + message = Regex.Replace(message, @"[T]+[S]+|[C]+(?=[IEY])|[Z]+|[P][S]+|[T](?=[I])", "TH"); + message = Regex.Replace(message, @"[Tt]+[Ss]+|[Cc]+(?=[IiEeYy])|[Zz]+|[Pp][Ss]+|[Tt](?=[Ii])", "th"); + // handles ex + message = Regex.Replace(message, @"(?![E])[X]", "KTH"); + message = Regex.Replace(message, @"(?![Ee])[Xx]", "kth"); + // handles sth and s + message = Regex.Replace(message, "[S]+[T]?[H]?", "TH"); + message = Regex.Replace(message, "[Ss]+[Tt]?[Hh]?", "th"); + + args.Message = message; + } +} diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index 3e315d3889..28c0ecf794 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -31,3 +31,6 @@ trait-accentless-desc = You don't have the accent that your species would usuall trait-wheelchair-bound-name = Wheelchair Bound trait-wheelchair-bound-desc = You cannot move without your wheelchair. Wheelchair included. + +trait-frontal-lisp-name = Frontal Lisp +trait-frontal-lisp-desc = You thpeak with a lithp diff --git a/Resources/Prototypes/Traits/disabilities.yml b/Resources/Prototypes/Traits/disabilities.yml index 9869eb8536..c25e4c74c3 100644 --- a/Resources/Prototypes/Traits/disabilities.yml +++ b/Resources/Prototypes/Traits/disabilities.yml @@ -57,3 +57,10 @@ components: - type: WheelchairBound - type: LegsParalyzed + +- type: trait + id: FrontalLisp + name: trait-frontal-lisp-name + description: trait-frontal-lisp-desc + components: + - type: FrontalLisp