mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System.Collections.Frozen;
|
||
using Content.Shared.Random.Helpers;
|
||
using Content.Shared.Speech.Components;
|
||
using Robust.Shared.Random;
|
||
using Robust.Shared.Timing;
|
||
|
||
namespace Content.Shared.Speech.EntitySystems;
|
||
|
||
public sealed partial class BarkAccentSystem : RelayAccentSystem<BarkAccentComponent>
|
||
{
|
||
[Dependency] private IGameTiming _timing = default!;
|
||
[Dependency] private IRobustRandom _random = default!;
|
||
|
||
private static readonly IReadOnlyList<string> Barks =
|
||
[
|
||
" Гав!", " ГАВ", " вуф-вуф" // Corvax-Localization
|
||
];
|
||
|
||
private static readonly FrozenDictionary<string, string> SpecialWords =
|
||
new Dictionary<string, string>
|
||
{
|
||
{ "ah", "arf" },
|
||
{ "Ah", "Arf" },
|
||
{ "oh", "oof" },
|
||
{ "Oh", "Oof" },
|
||
//Corvax-Localization-Start
|
||
{ "га", "гаф" },
|
||
{ "Га", "Гаф" },
|
||
{ "угу", "вуф" },
|
||
{ "Угу", "Вуф" },
|
||
//Corvax-Localization-End
|
||
}.ToFrozenDictionary();
|
||
|
||
public override string Accentuate(string message, Entity<BarkAccentComponent>? ent = null)
|
||
{
|
||
var random = ent.HasValue
|
||
? SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(ent.Value))
|
||
: _random;
|
||
|
||
foreach (var (word, repl) in SpecialWords)
|
||
{
|
||
message = message.Replace(word, repl);
|
||
}
|
||
|
||
return message.Replace("!", random.Pick(Barks))
|
||
.Replace("l", "r")
|
||
.Replace("L", "R")
|
||
.Replace("л", "р").Replace("Л", "Р");//Corvax-Localization
|
||
}
|
||
}
|