Files
space-station-14/Content.Server/Speech/EntitySystems/GermanAccentSystem.cs
Pieter-Jan Briers b47db86189 Remove bad accents (#42880)
These are just bad bloat content that doesn't even work properly or has obvious issues if you look at it too closely. Remove.

Removed:
* Dwarvish
* Italian
* German (word replacements only)
* Southern
* Cowboy (I have a friend from Texas who hates it)
* Pirate (trait removal, hat still works)
2026-02-12 15:42:34 +01:00

83 lines
2.8 KiB
C#

using System.Text;
using System.Text.RegularExpressions;
using Content.Server.Speech.Components;
using Content.Shared.Speech;
using Robust.Shared.Random;
namespace Content.Server.Speech.EntitySystems;
public sealed class GermanAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
private static readonly Regex RegexTh = new(@"(?<=\s|^)th", RegexOptions.IgnoreCase);
private static readonly Regex RegexThe = new(@"(?<=\s|^)the(?=\s|$)", RegexOptions.IgnoreCase);
public override void Initialize()
{
SubscribeLocalEvent<GermanAccentComponent, AccentGetEvent>(OnAccent);
}
public string Accentuate(string message)
{
var msg = message;
// rarely, "the" should become "das" instead of "ze"
// TODO: The ReplacementAccentSystem should have random replacements this built-in.
foreach (Match match in RegexThe.Matches(msg))
{
if (_random.Prob(0.3f))
{
// just shift T, H and E over to D, A and S to preserve capitalization
msg = msg.Substring(0, match.Index) +
(char)(msg[match.Index] - 16) +
(char)(msg[match.Index + 1] - 7) +
(char)(msg[match.Index + 2] + 14) +
msg.Substring(match.Index + 3);
}
}
// replace th with zh (for zhis, zhat, etc. the => ze is handled by replacements already)
var msgBuilder = new StringBuilder(msg);
foreach (Match match in RegexTh.Matches(msg))
{
// just shift the T over to a Z to preserve capitalization
msgBuilder[match.Index] = (char) (msgBuilder[match.Index] + 6);
}
// Random Umlaut Time! (The joke outweighs the emotional damage this inflicts on actual Germans)
var umlautCooldown = 0;
for (var i = 0; i < msgBuilder.Length; i++)
{
if (umlautCooldown == 0)
{
if (_random.Prob(0.1f)) // 10% of all eligible vowels become umlauts)
{
msgBuilder[i] = msgBuilder[i] switch
{
'A' => 'Ä',
'a' => 'ä',
'O' => 'Ö',
'o' => 'ö',
'U' => 'Ü',
'u' => 'ü',
_ => msgBuilder[i]
};
umlautCooldown = 4;
}
}
else
{
umlautCooldown--;
}
}
return msgBuilder.ToString();
}
private void OnAccent(Entity<GermanAccentComponent> ent, ref AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}