forked from SerbiaStrong-220/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Vox Accent * Update VoxAccentComponent.cs * Update Content.Server/SS220/Speech/Components/VoxAccentComponent.cs Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com> * Update Content.Server/SS220/Speech/Components/VoxAccentComponent.cs Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com> * Update Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.cs Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com> * Update Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.cs Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com> --------- Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
Content.Server/SS220/Speech/Components/VoxAccentComponent.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,11 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
namespace Content.Server.SS220.Speech.Components; | ||
|
||
/// <summary> | ||
/// The vox accent component. Changes "k" to "kk" or "kek", and "ch" to "ch" or "chech" | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class VoxAccentComponent : Component | ||
{ | ||
} |
53 changes: 53 additions & 0 deletions
53
Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.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,53 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using System.Text.RegularExpressions; | ||
using Robust.Shared.Random; | ||
using Content.Server.SS220.Speech.Components; | ||
using Content.Server.Speech; | ||
|
||
namespace Content.Server.SS220.Speech.EntitySystems; | ||
|
||
public sealed class VoxAccentSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
private static readonly Regex RegexLowerK = new("k+"); | ||
private static readonly Regex RegexUpperK = new("K+"); | ||
private static readonly Regex RegexRuLowerK = new("к+"); | ||
private static readonly Regex RegexRuUpperK = new("К+"); | ||
private static readonly Regex RegexLowerCH = new("ch+"); | ||
private static readonly Regex RegexUpperCH = new("CH+"); | ||
private static readonly Regex RegexRuLowerCH = new("ч+"); | ||
private static readonly Regex RegexRuUpperCH = new("Ч+"); | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<VoxAccentComponent, AccentGetEvent>(OnAccent); | ||
} | ||
|
||
private void OnAccent(Entity<VoxAccentComponent> entity, ref AccentGetEvent args) | ||
{ | ||
var message = args.Message; | ||
|
||
// k into kk or kek | ||
message = RegexLowerK.Replace(message, _random.Pick(new List<string>() { "kk", "kek" })); | ||
// K into KK or KEK | ||
message = RegexUpperK.Replace(message, _random.Pick(new List<string>() { "KK", "KEK" })); | ||
// к в кк или кик | ||
message = RegexRuLowerK.Replace(message, _random.Pick(new List<string>() { "кк", "кик" })); | ||
// К в КК или КИК | ||
message = RegexRuUpperK.Replace(message, _random.Pick(new List<string>() { "КК", "КИК" })); | ||
|
||
// ch into chch or chech | ||
message = RegexLowerCH.Replace(message, _random.Pick(new List<string>() { "chch", "chech" })); | ||
// CH into CHCH or CHECH | ||
message = RegexUpperCH.Replace(message, _random.Pick(new List<string>() { "CHCH", "CHECH" })); | ||
// ч в чч или чич | ||
message = RegexRuLowerCH.Replace(message, _random.Pick(new List<string>() { "чч", "чич" })); | ||
// Ч в ЧЧ или ЧИЧ | ||
message = RegexRuUpperCH.Replace(message, _random.Pick(new List<string>() { "ЧЧ", "ЧИЧ" })); | ||
|
||
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