Accents Event to Shared (#38948)

* 27 file diff

* 27 file diff 2

* Apply suggestions from code review

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Princess Cheeseballs
2025-07-12 13:52:51 -07:00
committed by GitHub
parent cfe825b0e3
commit 367ff79006
27 changed files with 62 additions and 37 deletions

View File

@@ -1,44 +1,23 @@
using System.Text.RegularExpressions;
using Content.Server.Chat;
using Content.Server.Chat.Systems;
using Content.Shared.Speech;
namespace Content.Server.Speech
namespace Content.Server.Speech;
public sealed class AccentSystem : EntitySystem
{
public sealed class AccentSystem : EntitySystem
public static readonly Regex SentenceRegex = new(@"(?<=[\.!\?‽])(?![\.!\?‽])", RegexOptions.Compiled);
public override void Initialize()
{
public static readonly Regex SentenceRegex = new(@"(?<=[\.!\?‽])(?![\.!\?‽])", RegexOptions.Compiled);
public override void Initialize()
{
SubscribeLocalEvent<TransformSpeechEvent>(AccentHandler);
}
private void AccentHandler(TransformSpeechEvent args)
{
var accentEvent = new AccentGetEvent(args.Sender, args.Message);
RaiseLocalEvent(args.Sender, accentEvent, true);
args.Message = accentEvent.Message;
}
SubscribeLocalEvent<TransformSpeechEvent>(AccentHandler);
}
public sealed class AccentGetEvent : EntityEventArgs
private void AccentHandler(TransformSpeechEvent args)
{
/// <summary>
/// The entity to apply the accent to.
/// </summary>
public EntityUid Entity { get; }
var accentEvent = new AccentGetEvent(args.Sender, args.Message);
/// <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;
}
RaiseLocalEvent(args.Sender, accentEvent, true);
args.Message = accentEvent.Message;
}
}