]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Added lisp as a character trait (#20350)
authordahnte <70238020+dahnte@users.noreply.github.com>
Wed, 20 Sep 2023 04:51:50 +0000 (21:51 -0700)
committerGitHub <noreply@github.com>
Wed, 20 Sep 2023 04:51:50 +0000 (21:51 -0700)
Content.Server/Speech/Components/FrontalLispComponent.cs [new file with mode: 0644]
Content.Server/Speech/EntitySystems/FrontalLispSystem.cs [new file with mode: 0644]
Resources/Locale/en-US/traits/traits.ftl
Resources/Prototypes/Traits/disabilities.yml

diff --git a/Content.Server/Speech/Components/FrontalLispComponent.cs b/Content.Server/Speech/Components/FrontalLispComponent.cs
new file mode 100644 (file)
index 0000000..dbf1ccc
--- /dev/null
@@ -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 (file)
index 0000000..6ee5485
--- /dev/null
@@ -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<FrontalLispComponent, AccentGetEvent>(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;
+    }
+}
index 3e315d3889d8b9435265ba5d0cbc9af294ef6730..28c0ecf79446f8e6cdd05fa2e401362ab79ed345 100644 (file)
@@ -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
index 9869eb8536ac82da7fdb09a2b3caf2d619274068..c25e4c74c3ac82a4c95b29a0d743a1e87cf735e8 100644 (file)
   components:
     - type: WheelchairBound
     - type: LegsParalyzed
+
+- type: trait
+  id: FrontalLisp
+  name: trait-frontal-lisp-name
+  description: trait-frontal-lisp-desc
+  components:
+    - type: FrontalLisp