Files
wylab-station-14/Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs
qwerltaz 20c962aae1 [april fools] The world feels different today. You examine objects around you but can't quite make out what's in front of you. (#35879)
* maybeAccentuate

* accentuate examine nodes

* working prototype

* random accentuator

* fix SingleAccentuator.cs

* french, mumble, slurred

* mobster, pirate, stutter

* remove examine prediction (for one day)

* random accents per examine, not per sentence

* Revert "random accents per examine, not per sentence"

This reverts commit 0dfa644bb760e4b3f760f43db8870f43ea75e64d.

* crew manifest

* tweak examine reaccentuation chance

* alert level announcement

* event centcom announcements

* tweak accent system signatures

* nuke annoucement, tweak manifest chance

* accentuation rarer and a bit more messed up

* examine tooltips

* more centcom announcements

* reformat

* sophisticated reformatting

* less

* tweak

---------

Co-authored-by: Milon <milonpl.git@proton.me>
2025-03-31 14:35:12 +02:00

52 lines
1.5 KiB
C#

using Content.Server.Speech.Components;
using System.Text.RegularExpressions;
namespace Content.Server.Speech.EntitySystems;
/// <summary>
/// System that gives the speaker a faux-French accent.
/// </summary>
public sealed class FrenchAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
private static readonly Regex RegexTh = new(@"th", RegexOptions.IgnoreCase);
private static readonly Regex RegexStartH = new(@"(?<!\w)h", RegexOptions.IgnoreCase);
private static readonly Regex RegexSpacePunctuation = new(@"(?<=\w\w)[!?;:](?!\w)", RegexOptions.IgnoreCase);
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FrenchAccentComponent, AccentGetEvent>(OnAccentGet);
}
public string Accentuate(string message, FrenchAccentComponent _)
{
return Accentuate(message);
}
public string Accentuate(string message)
{
var msg = message;
msg = _replacement.ApplyReplacements(msg, "french");
// replaces th with z
msg = RegexTh.Replace(msg, "'z");
// replaces h with ' at the start of words.
msg = RegexStartH.Replace(msg, "'");
// spaces out ! ? : and ;.
msg = RegexSpacePunctuation.Replace(msg, " $&");
return msg;
}
private void OnAccentGet(EntityUid uid, FrenchAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);
}
}