using System.Text.RegularExpressions; using Content.Shared.Speech.Components; namespace Content.Shared.Speech.EntitySystems; public sealed partial class SlowAccentSystem : RelayAccentSystem { /// /// Matches whitespace characters or commas (with or without a space after them). /// private static readonly Regex WordEndings = new("\\s|, |,"); /// /// Matches the end of the string only if the last character is a "word" character. /// private static readonly Regex NoFinalPunctuation = new("\\w\\z"); public override string Accentuate(string message, Entity? ent = null) { // Add... some... delay... between... each... word message = WordEndings.Replace(message, "... "); // Add "..." to the end, if the last character is part of a word... if (NoFinalPunctuation.IsMatch(message)) message += "..."; return message; } }