forked from space-wizards/space-station-14
-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1571 from Darkmajia/accent-stuff
gray and dwarf accent improvements
- Loading branch information
Showing
5 changed files
with
66 additions
and
20 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
Content.Server/_Impstation/Speech/Components/DwarfAccentComponent.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 @@ | ||
namespace Content.Server.Speech.Components; | ||
|
||
[RegisterComponent] | ||
public sealed partial class DwarfAccentComponent : Component | ||
{ | ||
} |
38 changes: 38 additions & 0 deletions
38
Content.Server/_Impstation/Speech/EntitySystems/DwarfAccentSystem.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,38 @@ | ||
using System.Text.RegularExpressions; | ||
using Content.Server.Speech.Components; | ||
|
||
namespace Content.Server.Speech.EntitySystems; | ||
|
||
public sealed class DwarfAccentComponentSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!; | ||
|
||
private static readonly Regex RegexAhAmContractionLower = new(@"(?<!^)(?<!\.\s+)\b[Aa]'[Mm]\b"); | ||
private static readonly Regex RegexAhAmContractionUpperLeft = new(@"(?<=\b[A-Z]+.)\b[Aa]'[Mm]\b"); | ||
private static readonly Regex RegexAhAmContractionUpperRight = new(@"\b[Aa]'[Mm]\b(?=.[A-Z]+\b)"); | ||
private static readonly Regex RegexAhLower = new(@"(?<!^)(?<!\.\s+)\b[Aa]h\b"); | ||
private static readonly Regex RegexAhUpperLeft = new(@"(?<=\b[A-Z]+.)\b[Aa]h\b"); | ||
private static readonly Regex RegexAhUpperRight = new(@"\b[Aa]h\b(?=.[A-Z]+\b)"); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<DwarfAccentComponent, AccentGetEvent>(OnAccent); | ||
} | ||
|
||
private void OnAccent(EntityUid uid, DwarfAccentComponent component, AccentGetEvent args) | ||
{ | ||
var message = args.Message; | ||
|
||
message = _replacement.ApplyReplacements(message, "dwarf"); | ||
|
||
message = RegexAhAmContractionLower.Replace(message, "a'm"); | ||
message = RegexAhAmContractionUpperLeft.Replace(message, "A'M"); | ||
message = RegexAhAmContractionUpperRight.Replace(message, "A'M"); | ||
message = RegexAhLower.Replace(message, "ah"); | ||
message = RegexAhUpperLeft.Replace(message, "AH"); | ||
message = RegexAhUpperRight.Replace(message, "AH"); | ||
|
||
args.Message = message; | ||
} | ||
} |
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
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
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