2024-03-31 00:39:40 -04:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using Content.Server.Speech.Components;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Speech.EntitySystems;
|
|
|
|
|
|
|
|
|
|
public sealed class SouthernAccentSystem : EntitySystem
|
|
|
|
|
{
|
2024-05-06 00:57:32 +02:00
|
|
|
private static readonly Regex RegexIng = new(@"ing\b");
|
|
|
|
|
private static readonly Regex RegexAnd = new(@"\band\b");
|
|
|
|
|
private static readonly Regex RegexDve = new("d've");
|
|
|
|
|
|
2024-03-31 00:39:40 -04:00
|
|
|
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
|
2024-05-06 00:57:32 +02:00
|
|
|
|
2024-03-31 00:39:40 -04:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
SubscribeLocalEvent<SouthernAccentComponent, AccentGetEvent>(OnAccent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAccent(EntityUid uid, SouthernAccentComponent component, AccentGetEvent args)
|
|
|
|
|
{
|
|
|
|
|
var message = args.Message;
|
|
|
|
|
|
|
|
|
|
message = _replacement.ApplyReplacements(message, "southern");
|
|
|
|
|
|
|
|
|
|
//They shoulda started runnin' an' hidin' from me!
|
2024-05-06 00:57:32 +02:00
|
|
|
message = RegexIng.Replace(message, "in'");
|
|
|
|
|
message = RegexAnd.Replace(message, "an'");
|
|
|
|
|
message = RegexDve.Replace(message, "da");
|
2024-03-31 00:39:40 -04:00
|
|
|
args.Message = message;
|
|
|
|
|
}
|
|
|
|
|
};
|