Files
OldThink/Content.Server/Speech/AccentSystem.cs

45 lines
1.2 KiB
C#
Raw Normal View History

using System.Text.RegularExpressions;
2022-03-30 22:21:58 -07:00
using Content.Server.Chat;
using Content.Server.Chat.Systems;
namespace Content.Server.Speech
{
public sealed class AccentSystem : EntitySystem
{
public static readonly Regex SentenceRegex = new(@"(?<=[\.!\?])", RegexOptions.Compiled);
public override void Initialize()
{
2022-03-30 22:21:58 -07:00
SubscribeLocalEvent<TransformSpeechEvent>(AccentHandler);
}
2022-03-30 22:21:58 -07:00
private void AccentHandler(TransformSpeechEvent args)
{
2022-03-30 22:21:58 -07:00
var accentEvent = new AccentGetEvent(args.Sender, args.Message);
RaiseLocalEvent(args.Sender, accentEvent, true);
2022-03-30 22:21:58 -07:00
args.Message = accentEvent.Message;
}
}
public sealed class AccentGetEvent : EntityEventArgs
{
/// <summary>
/// The entity to apply the accent to.
/// </summary>
public EntityUid Entity { get; }
/// <summary>
/// The message to apply the accent transformation to.
/// Modify this to apply the accent.
/// </summary>
public string Message { get; set; }
public AccentGetEvent(EntityUid entity, string message)
{
Entity = entity;
Message = message;
}
}
}