From 367ff79006615494f501bde74abcb6f6e5c0057f Mon Sep 17 00:00:00 2001 From: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Date: Sat, 12 Jul 2025 13:52:51 -0700 Subject: [PATCH] Accents Event to Shared (#38948) * 27 file diff * 27 file diff 2 * Apply suggestions from code review --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- Content.Server/Speech/AccentSystem.cs | 45 +++++-------------- .../EntitySystems/BackwardsAccentSystem.cs | 1 + .../Speech/EntitySystems/BarkAccentSystem.cs | 1 + .../EntitySystems/BleatingAccentSystem.cs | 1 + .../DamagedSiliconAccentSystem.cs | 1 + .../EntitySystems/FrenchAccentSystem.cs | 5 ++- .../Speech/EntitySystems/FrontalLispSystem.cs | 1 + .../EntitySystems/GermanAccentSystem.cs | 3 +- .../EntitySystems/LizardAccentSystem.cs | 1 + .../EntitySystems/MobsterAccentSystem.cs | 1 + .../EntitySystems/MonkeyAccentSystem.cs | 1 + .../Speech/EntitySystems/MothAccentSystem.cs | 1 + .../EntitySystems/MumbleAccentSystem.cs | 1 + .../Speech/EntitySystems/OwOAccentSystem.cs | 1 + .../EntitySystems/ParrotAccentSystem.cs | 1 + .../EntitySystems/PirateAccentSystem.cs | 1 + .../EntitySystems/RatvarianLanguageSystem.cs | 1 + .../EntitySystems/ReplacementAccentSystem.cs | 1 + .../EntitySystems/RussianAccentSystem.cs | 1 + .../EntitySystems/ScrambledAccentSystem.cs | 1 + .../EntitySystems/SkeletonAccentSystem.cs | 1 + .../Speech/EntitySystems/SlowAccentSystem.cs | 1 + .../Speech/EntitySystems/SlurredSystem.cs | 1 + .../EntitySystems/SouthernAccentSystem.cs | 1 + .../EntitySystems/SpanishAccentSystem.cs | 1 + .../Speech/EntitySystems/StutteringSystem.cs | 1 + Content.Shared/Speech/AccentEvent.cs | 21 +++++++++ 27 files changed, 61 insertions(+), 36 deletions(-) create mode 100644 Content.Shared/Speech/AccentEvent.cs diff --git a/Content.Server/Speech/AccentSystem.cs b/Content.Server/Speech/AccentSystem.cs index 7e29f02cae..e413dd52f8 100644 --- a/Content.Server/Speech/AccentSystem.cs +++ b/Content.Server/Speech/AccentSystem.cs @@ -1,44 +1,23 @@ using System.Text.RegularExpressions; -using Content.Server.Chat; using Content.Server.Chat.Systems; +using Content.Shared.Speech; -namespace Content.Server.Speech -{ - public sealed class AccentSystem : EntitySystem - { - public static readonly Regex SentenceRegex = new(@"(?<=[\.!\?‽])(?![\.!\?‽])", RegexOptions.Compiled); - - public override void Initialize() - { - SubscribeLocalEvent(AccentHandler); - } +namespace Content.Server.Speech; - private void AccentHandler(TransformSpeechEvent args) - { - var accentEvent = new AccentGetEvent(args.Sender, args.Message); +public sealed class AccentSystem : EntitySystem +{ + public static readonly Regex SentenceRegex = new(@"(?<=[\.!\?‽])(?![\.!\?‽])", RegexOptions.Compiled); - RaiseLocalEvent(args.Sender, accentEvent, true); - args.Message = accentEvent.Message; - } + public override void Initialize() + { + SubscribeLocalEvent(AccentHandler); } - public sealed class AccentGetEvent : EntityEventArgs + private void AccentHandler(TransformSpeechEvent args) { - /// - /// The entity to apply the accent to. - /// - public EntityUid Entity { get; } - - /// - /// The message to apply the accent transformation to. - /// Modify this to apply the accent. - /// - public string Message { get; set; } + var accentEvent = new AccentGetEvent(args.Sender, args.Message); - public AccentGetEvent(EntityUid entity, string message) - { - Entity = entity; - Message = message; - } + RaiseLocalEvent(args.Sender, accentEvent, true); + args.Message = accentEvent.Message; } } diff --git a/Content.Server/Speech/EntitySystems/BackwardsAccentSystem.cs b/Content.Server/Speech/EntitySystems/BackwardsAccentSystem.cs index db69c86995..cad96e7d04 100644 --- a/Content.Server/Speech/EntitySystems/BackwardsAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/BackwardsAccentSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems { diff --git a/Content.Server/Speech/EntitySystems/BarkAccentSystem.cs b/Content.Server/Speech/EntitySystems/BarkAccentSystem.cs index a6e5b68ffc..927b1259ad 100644 --- a/Content.Server/Speech/EntitySystems/BarkAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/BarkAccentSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems diff --git a/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs b/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs index 903377477e..8dc358a4b4 100644 --- a/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/DamagedSiliconAccentSystem.cs b/Content.Server/Speech/EntitySystems/DamagedSiliconAccentSystem.cs index 47f36cafc4..d4a37a07cd 100644 --- a/Content.Server/Speech/EntitySystems/DamagedSiliconAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/DamagedSiliconAccentSystem.cs @@ -4,6 +4,7 @@ using Content.Server.PowerCell; using Content.Shared.Speech.Components; using Content.Shared.Damage; using Content.Shared.FixedPoint; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs b/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs index 1b7c46e13a..caefe3ef2d 100644 --- a/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs @@ -1,5 +1,6 @@ -using Content.Server.Speech.Components; using System.Text.RegularExpressions; +using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; @@ -32,7 +33,7 @@ public sealed class FrenchAccentSystem : EntitySystem // spaces out ! ? : and ;. msg = RegexSpacePunctuation.Replace(msg, " $&"); - + // replaces th with 'z or 's depending on the case foreach (Match match in RegexTh.Matches(msg)) { diff --git a/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs b/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs index 1508a8b2d4..b3f5ff53dc 100644 --- a/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs +++ b/Content.Server/Speech/EntitySystems/FrontalLispSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/GermanAccentSystem.cs b/Content.Server/Speech/EntitySystems/GermanAccentSystem.cs index 1973d38afb..94a5606178 100644 --- a/Content.Server/Speech/EntitySystems/GermanAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/GermanAccentSystem.cs @@ -1,7 +1,8 @@ using System.Text; +using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; -using System.Text.RegularExpressions; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/LizardAccentSystem.cs b/Content.Server/Speech/EntitySystems/LizardAccentSystem.cs index 81a57cb848..48a4a4630c 100644 --- a/Content.Server/Speech/EntitySystems/LizardAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/LizardAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/MobsterAccentSystem.cs b/Content.Server/Speech/EntitySystems/MobsterAccentSystem.cs index 5906bf3ed4..6048db5eb2 100644 --- a/Content.Server/Speech/EntitySystems/MobsterAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/MobsterAccentSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/MonkeyAccentSystem.cs b/Content.Server/Speech/EntitySystems/MonkeyAccentSystem.cs index f2813d8245..0f42d93324 100644 --- a/Content.Server/Speech/EntitySystems/MonkeyAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/MonkeyAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/MothAccentSystem.cs b/Content.Server/Speech/EntitySystems/MothAccentSystem.cs index 84b79d4ce9..3bf46459ac 100644 --- a/Content.Server/Speech/EntitySystems/MothAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/MothAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs b/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs index 57469a25aa..27679c9134 100644 --- a/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Chat.Systems; using Content.Server.Speech.Components; using Content.Shared.Chat.Prototypes; +using Content.Shared.Speech; using Content.Shared.Speech.Components; using Robust.Shared.Prototypes; diff --git a/Content.Server/Speech/EntitySystems/OwOAccentSystem.cs b/Content.Server/Speech/EntitySystems/OwOAccentSystem.cs index 2b3d5aa3d4..ff930e524a 100644 --- a/Content.Server/Speech/EntitySystems/OwOAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/OwOAccentSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems diff --git a/Content.Server/Speech/EntitySystems/ParrotAccentSystem.cs b/Content.Server/Speech/EntitySystems/ParrotAccentSystem.cs index ae8fe522b9..9bd3be25ae 100644 --- a/Content.Server/Speech/EntitySystems/ParrotAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/ParrotAccentSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/PirateAccentSystem.cs b/Content.Server/Speech/EntitySystems/PirateAccentSystem.cs index 84298cbf01..ff2c5913e0 100644 --- a/Content.Server/Speech/EntitySystems/PirateAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/PirateAccentSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; using System.Text.RegularExpressions; diff --git a/Content.Server/Speech/EntitySystems/RatvarianLanguageSystem.cs b/Content.Server/Speech/EntitySystems/RatvarianLanguageSystem.cs index 508f85aac2..39b040b75f 100644 --- a/Content.Server/Speech/EntitySystems/RatvarianLanguageSystem.cs +++ b/Content.Server/Speech/EntitySystems/RatvarianLanguageSystem.cs @@ -1,5 +1,6 @@ using System.Text; using System.Text.RegularExpressions; +using Content.Shared.Speech; using Content.Shared.Speech.Components; using Content.Shared.Speech.EntitySystems; using Content.Shared.StatusEffect; diff --git a/Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs b/Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs index 656a72b3f9..5b215e9bea 100644 --- a/Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Text.RegularExpressions; using Content.Server.Speech.Components; using Content.Server.Speech.Prototypes; +using Content.Shared.Speech; using JetBrains.Annotations; using Robust.Shared.Prototypes; using Robust.Shared.Random; diff --git a/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs b/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs index 49aab38e2b..5c49ecbde7 100644 --- a/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/RussianAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/ScrambledAccentSystem.cs b/Content.Server/Speech/EntitySystems/ScrambledAccentSystem.cs index 8a61c0ea50..d685edc38b 100644 --- a/Content.Server/Speech/EntitySystems/ScrambledAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/ScrambledAccentSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems diff --git a/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs b/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs index 1b773f1a5a..73d8c0665e 100644 --- a/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Robust.Shared.Random; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/SlowAccentSystem.cs b/Content.Server/Speech/EntitySystems/SlowAccentSystem.cs index 5a94b0a4d6..0a4ac02f3f 100644 --- a/Content.Server/Speech/EntitySystems/SlowAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/SlowAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/SlurredSystem.cs b/Content.Server/Speech/EntitySystems/SlurredSystem.cs index fbfe72f17f..5ac1ba037f 100644 --- a/Content.Server/Speech/EntitySystems/SlurredSystem.cs +++ b/Content.Server/Speech/EntitySystems/SlurredSystem.cs @@ -1,6 +1,7 @@ using System.Text; using Content.Server.Speech.Components; using Content.Shared.Drunk; +using Content.Shared.Speech; using Content.Shared.Speech.EntitySystems; using Content.Shared.StatusEffect; using Robust.Shared.Prototypes; diff --git a/Content.Server/Speech/EntitySystems/SouthernAccentSystem.cs b/Content.Server/Speech/EntitySystems/SouthernAccentSystem.cs index c1f8a0be30..6bf64ccabd 100644 --- a/Content.Server/Speech/EntitySystems/SouthernAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/SouthernAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems; diff --git a/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs b/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs index 08642014c9..cf0c7dfcd2 100644 --- a/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs +++ b/Content.Server/Speech/EntitySystems/SpanishAccentSystem.cs @@ -1,5 +1,6 @@ using System.Text; using Content.Server.Speech.Components; +using Content.Shared.Speech; namespace Content.Server.Speech.EntitySystems { diff --git a/Content.Server/Speech/EntitySystems/StutteringSystem.cs b/Content.Server/Speech/EntitySystems/StutteringSystem.cs index d6e3c0b749..f47bff3523 100644 --- a/Content.Server/Speech/EntitySystems/StutteringSystem.cs +++ b/Content.Server/Speech/EntitySystems/StutteringSystem.cs @@ -1,6 +1,7 @@ using System.Text; using System.Text.RegularExpressions; using Content.Server.Speech.Components; +using Content.Shared.Speech; using Content.Shared.Speech.EntitySystems; using Content.Shared.StatusEffect; using Robust.Shared.Random; diff --git a/Content.Shared/Speech/AccentEvent.cs b/Content.Shared/Speech/AccentEvent.cs new file mode 100644 index 0000000000..9b90709959 --- /dev/null +++ b/Content.Shared/Speech/AccentEvent.cs @@ -0,0 +1,21 @@ +namespace Content.Shared.Speech; + +public sealed class AccentGetEvent : EntityEventArgs +{ + /// + /// The entity to apply the accent to. + /// + public EntityUid Entity { get; } + + /// + /// The message to apply the accent transformation to. + /// Modify this to apply the accent. + /// + public string Message { get; set; } + + public AccentGetEvent(EntityUid entity, string message) + { + Entity = entity; + Message = message; + } +} -- 2.52.0