-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2024-07-15-YeetShips' of https://github.com/dvir001/fro…
…ntier-station-14 into 2024-07-15-YeetShips
- Loading branch information
Showing
135 changed files
with
14,086 additions
and
4,417 deletions.
There are no files selected for viewing
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
52 changes: 40 additions & 12 deletions
52
Content.Server/_NF/Speech/EntitySystems/GoblinAccentSystem.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 |
---|---|---|
@@ -1,31 +1,59 @@ | ||
using Content.Server._NF.Speech.Components; | ||
using Content.Server.Speech; | ||
using Content.Server.Speech.EntitySystems; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Content.Server._NF.Speech.EntitySystems; | ||
|
||
// The whole code is a copy of SouthernAccentSystem by UBlueberry (https://github.com/UBlueberry) | ||
public sealed class GoblinAccentSystem : EntitySystem | ||
{ | ||
private static readonly Regex RegexIng = new(@"(in)g\b", RegexOptions.IgnoreCase); | ||
private static readonly Regex RegexAnd = new(@"\b(an)d\b", RegexOptions.IgnoreCase); | ||
private static readonly Regex RegexEr = new(@"([^\WpPfF])er\b"); // Keep "er", "per", "Per", "fer" and "Fer" | ||
private static readonly Regex RegexErUpper = new(@"([^\WpPfF])ER\b"); // Keep "ER", "PER" and "FER" | ||
private static readonly Regex RegexTwoLetterEr = new(@"(\w\w)er\b"); // Replace "..XXer", e.g. "super"->"supah" | ||
private static readonly Regex RegexTwoLetterErUpper = new(@"(\w\w)ER\b"); // Replace "..XXER", e.g. "SUPER"->"SUPAH" | ||
private static readonly Regex RegexErs = new(@"(\w)ers\b"); // Replace "..XXers", e.g. "fixers"->"fixas" | ||
private static readonly Regex RegexErsUpper = new(@"(\w)ERS\b"); // Replace "..XXers", e.g. "fixers"->"fixas" | ||
private static readonly Regex RegexTt = new(@"([aeiouy])tt", RegexOptions.IgnoreCase); | ||
private static readonly Regex RegexOf = new(@"\b(o)f\b", RegexOptions.IgnoreCase); | ||
private static readonly Regex RegexThe = new(@"\bthe\b"); | ||
private static readonly Regex RegexTheUpper = new(@"\bTHE\b"); | ||
private static readonly Regex RegexH = new(@"\bh", RegexOptions.IgnoreCase); | ||
private static readonly Regex RegexSelf = new(@"self\b"); | ||
private static readonly Regex RegexSelfUpper = new(@"SELF\b"); | ||
|
||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<GoblinAccentComponent, AccentGetEvent>(OnAccentGet); | ||
SubscribeLocalEvent<GoblinAccentComponent, AccentGetEvent>(OnAccent); | ||
} | ||
|
||
// converts left word when typed into the right word. For example typing you becomes ye. | ||
public string Accentuate(string message, GoblinAccentComponent component) | ||
private void OnAccent(EntityUid uid, GoblinAccentComponent component, AccentGetEvent args) | ||
{ | ||
var msg = message; | ||
var message = args.Message; | ||
|
||
msg = _replacement.ApplyReplacements(msg, "goblin"); | ||
return msg; | ||
} | ||
message = _replacement.ApplyReplacements(message, "goblin_accent"); | ||
|
||
private void OnAccentGet(EntityUid uid, GoblinAccentComponent component, AccentGetEvent args) | ||
{ | ||
args.Message = Accentuate(args.Message, component); | ||
message = RegexIng.Replace(message, "$1'"); //ing->in', ING->IN' | ||
message = RegexAnd.Replace(message, "$1'"); //and->an', AND->AN' | ||
message = RegexEr.Replace(message, "$1ah"); | ||
message = RegexErUpper.Replace(message, "$1AH"); | ||
message = RegexTwoLetterEr.Replace(message, "$1ah"); | ||
message = RegexTwoLetterErUpper.Replace(message, "$1AH"); | ||
message = RegexErs.Replace(message, "$1as"); | ||
message = RegexErsUpper.Replace(message, "$1AS"); | ||
message = RegexTt.Replace(message, "$1'"); | ||
message = RegexH.Replace(message, "'"); | ||
message = RegexSelf.Replace(message, "sewf"); | ||
message = RegexSelfUpper.Replace(message, "SEWF"); | ||
message = RegexOf.Replace(message, "$1'"); //of->o', OF->O' | ||
message = RegexThe.Replace(message, "da"); | ||
message = RegexTheUpper.Replace(message, "DA"); | ||
|
||
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
Oops, something went wrong.