mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* move-accents-to-shared * Update AccentSystem.cs * Update ListeningSystem.cs * aaaaaa * Update AccentSystem.cs * oh god * aaooao * // * review * fix * Update VocalSystem.cs
29 lines
1,005 B
C#
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;
|
|
}
|
|
}
|