* pirate content * pirate content * merge * merge * update launchers * trying to fix launcher error * merge * merge * merge * fix for launchers * update to held cannon sprite * attempt to fix issue * first updates in long time * changes mostly to sprites * more sprite fixes * more sprite changes * json fixes * small update * new pirate crate * update * updae json * fix eva * update accent * fix accentcomp * improved pirate chest * accent localized * station to docks * modified the pirate ship * changed pda spawns for firstmate nad piratecaptain to passenger pdas * fixes * pirate accent * removed spacing in shotgun.yml * redo accent * fix * removed no spawn from helmet hardsuit * suffix capitalization * tweaks * a * jusdt fixing up the hi and yes which are both replacement and not replacement and replaced. * pirate accent fixes * desc fix --------- Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: AJCM <AJCM@tutanota.com> Co-authored-by: Kara <lunarautomaton6@gmail.com>
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Content.Server.Speech.Components;
|
|
using Robust.Shared.Random;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Content.Server.Speech.EntitySystems;
|
|
|
|
public sealed class PirateAccentSystem : EntitySystem
|
|
{
|
|
[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 = message;
|
|
|
|
msg = _replacement.ApplyReplacements(msg, "pirate");
|
|
|
|
if (!_random.Prob(component.YarrChance))
|
|
return msg;
|
|
|
|
var pick = _random.Pick(component.PirateWords);
|
|
// Reverse sanitize capital
|
|
msg = msg[0].ToString().ToLower() + msg.Remove(0, 1);
|
|
msg = Loc.GetString(pick) + " " + msg;
|
|
|
|
return msg;
|
|
}
|
|
|
|
private void OnAccentGet(EntityUid uid, PirateAccentComponent component, AccentGetEvent args)
|
|
{
|
|
args.Message = Accentuate(args.Message, component);
|
|
}
|
|
}
|