-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Accent Component and Accent System
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Content.Server/DeltaV/Speech/Components/ScottishAccentComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
31
Content.Server/DeltaV/Speech/EntitySystems/ScottishAccentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |