Skip to content

Commit

Permalink
Add Accent Component and Accent System
Browse files Browse the repository at this point in the history
  • Loading branch information
ps3moira committed Dec 28, 2023
1 parent ebe9a1d commit 8f97989
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[RegisterComponent]
[Access(typeof(ScottishAccentSystem))]
public sealed partial class ScottishAccentComponent : Component
{

}
31 changes: 31 additions & 0 deletions Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Server.Speech.Components;
using Robust.Shared.Random;
using System.Text.RegularExpressions;

namespace Content.Server.Speech.EntitySystems;

public sealed class ScottishAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ScottishAccentComponent, AccentGetEvent>(OnAccentGet);
}

// converts left word when typed into the right word. For example typing you becomes ye.
public string Accentuate(string message, ScottishAccentComponent component)
{
var msg = message;

msg = _replacement.ApplyReplacements(msg, "Scottish");
return msg;
}

private void OnAccentGet(EntityUid uid, ScottishAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);
}
}

0 comments on commit 8f97989

Please sign in to comment.