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:
committed by
GitHub
parent
cfe825b0e3
commit
367ff79006
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Server.PowerCell;
|
||||
using Content.Shared.Speech.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -32,7 +33,7 @@ public sealed class FrenchAccentSystem : EntitySystem
|
||||
|
||||
// spaces out ! ? : and ;.
|
||||
msg = RegexSpacePunctuation.Replace(msg, " $&");
|
||||
|
||||
|
||||
// replaces th with 'z or 's depending on the case
|
||||
foreach (Match match in RegexTh.Matches(msg))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Text;
|
||||
using Content.Server.Speech.Components;
|
||||
using Robust.Shared.Random;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Chat.Prototypes;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.Components;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Server.Speech.Prototypes;
|
||||
using Content.Shared.Speech;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Drunk;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Text;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Speech;
|
||||
using Content.Shared.Speech.EntitySystems;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
21
Content.Shared/Speech/AccentEvent.cs
Normal file
21
Content.Shared/Speech/AccentEvent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Content.Shared.Speech;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user