Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/Speech/AccentManager.cs
DrSmugleaf 5c0cf1b1a0 Use 'new' expression in places where the type is evident for content (#2590)
* Content.Client

* Content.Benchmarks

* Content.IntegrationTests

* Content.Server

* Content.Server.Database

* Content.Shared

* Content.Tests

* Merge fixes

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-27 21:00:49 +11: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(@"(?<=[\.!\?])");
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;
}
}
}