Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/Speech/AccentManager.cs
DrSmugleaf 74943a2770 Typo, redundant string interpolation, namespaces and imports cleanup (#2068)
* Readonly, typos and redundant string interpolations

* Namespaces

* Optimize imports

* Address reviews

* but actually

* Localize missing strings

* Remove redundant vars
2020-09-13 14:23:52 +02:00

39 lines
1.1 KiB
C#

using System.Text.RegularExpressions;
using Content.Server.Interfaces.Chat;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.Components.Mobs.Speech
{
public interface IAccentManager
{
public void Initialize();
}
public class AccentManager : IAccentManager
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IComponentManager _componentManager = default!;
public static readonly Regex SentenceRegex = new Regex(@"(?<=[\.!\?])");
public void Initialize()
{
IoCManager.InjectDependencies(this);
_chatManager.RegisterChatTransform(AccentHandler);
}
public string AccentHandler(IEntity player, string message)
{
//TODO: give accents a prio?
var accents = _componentManager.GetComponents<IAccentComponent>(player.Uid);
foreach (var accent in accents)
{
message = accent.Accentuate(message);
}
return message;
}
}
}