Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/Speech/AccentManager.cs
Exp c665e66318 Accent System (#1892)
* First Accent Prototype

* -RegisterSystem
-Fixed addaccent cmd
-Spanish accent

* -list is now ?
-Checks if the accent is already added
-Made components public

* owo whats this

* special word filter

* Eeeeeeeeee

* Better?

* -Use a delegate func
-Made some funcs not static
-Moved SentenceRegex

* InjectDependencies

* Name change?

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
2020-08-25 17:09:39 +02:00

42 lines
1.2 KiB
C#

using Content.Server.Interfaces.Chat;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
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;
}
}
}