mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-15 03:31:44 +01:00
* 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>
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System.Linq;
|
|
using Content.Server.Speech.Components;
|
|
using Robust.Shared.Random;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Content.Server.Speech.EntitySystems;
|
|
|
|
public sealed class PirateAccentSystem : EntitySystem
|
|
{
|
|
private static readonly Regex FirstWordAllCapsRegex = new(@"^(\S+)");
|
|
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<PirateAccentComponent, AccentGetEvent>(OnAccentGet);
|
|
}
|
|
|
|
// converts left word when typed into the right word. For example typing you becomes ye.
|
|
public string Accentuate(string message, PirateAccentComponent component)
|
|
{
|
|
var msg = _replacement.ApplyReplacements(message, "pirate");
|
|
|
|
if (!_random.Prob(component.YarrChance))
|
|
return msg;
|
|
//Checks if the first word of the sentence is all caps
|
|
//So the prefix can be allcapped and to not resanitize the captial
|
|
var firstWordAllCaps = !FirstWordAllCapsRegex.Match(msg).Value.Any(char.IsLower);
|
|
|
|
var pick = _random.Pick(component.PirateWords);
|
|
var pirateWord = Loc.GetString(pick);
|
|
// Reverse sanitize capital
|
|
if (!firstWordAllCaps)
|
|
msg = msg[0].ToString().ToLower() + msg.Remove(0, 1);
|
|
else
|
|
pirateWord = pirateWord.ToUpper();
|
|
msg = pirateWord + " " + msg;
|
|
|
|
return msg;
|
|
}
|
|
|
|
public string Accentuate(string message)
|
|
{
|
|
return Accentuate(message, new PirateAccentComponent { YarrChance = 0.3f });
|
|
}
|
|
|
|
private void OnAccentGet(EntityUid uid, PirateAccentComponent component, AccentGetEvent args)
|
|
{
|
|
args.Message = Accentuate(args.Message, component);
|
|
}
|
|
}
|