CatStation/Content.Shared/Speech/EntitySystems/SlowAccentSystem.cs
Pok 7a8fab78e3
Move Accents to Shared v2 (#44772)
* move-accents-to-shared

* Update AccentSystem.cs

* Update ListeningSystem.cs

* aaaaaa

* Update AccentSystem.cs

* oh god

* aaooao

* //

* review

* fix

* Update VocalSystem.cs
2026-07-25 22:29:39 +00:00

29 lines
1,005 B
C#

using System.Text.RegularExpressions;
using Content.Shared.Speech.Components;
namespace Content.Shared.Speech.EntitySystems;
public sealed partial class SlowAccentSystem : RelayAccentSystem<SlowAccentComponent>
{
/// <summary>
/// Matches whitespace characters or commas (with or without a space after them).
/// </summary>
private static readonly Regex WordEndings = new("\\s|, |,");
/// <summary>
/// Matches the end of the string only if the last character is a "word" character.
/// </summary>
private static readonly Regex NoFinalPunctuation = new("\\w\\z");
public override string Accentuate(string message, Entity<SlowAccentComponent>? 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;
}
}