using Content.Shared.Inventory; using Content.Shared.Speech.Components; using Content.Shared.StatusEffectNew; namespace Content.Shared.Speech.EntitySystems; /// /// Base system for accents that should apply both directly and when relayed through other entities. /// public abstract class RelayAccentSystem : EntitySystem where T : BaseAccentComponent { /// /// Systems this accent should run before for direct speech accenting. /// protected virtual Type[]? AccentBefore => null; /// /// Systems this accent should run after for direct speech accenting. /// protected virtual Type[]? AccentAfter => null; /// /// Systems this accent should run before for relayed speech accenting. /// protected virtual Type[]? RelayAccentBefore => AccentBefore; /// /// Systems this accent should run after for relayed speech accenting. /// protected virtual Type[]? RelayAccentAfter => AccentAfter; /// public override void Initialize() { SubscribeLocalEvent(OnAccent, before: AccentBefore, after: AccentAfter); SubscribeLocalEvent>(OnInventoryRelayAccent, before: RelayAccentBefore, after: RelayAccentAfter); SubscribeLocalEvent>(OnStatusEffectRelayAccent, before: RelayAccentBefore, after: RelayAccentAfter); } protected virtual void OnInventoryRelayAccent(Entity ent, ref InventoryRelayedEvent args) { if (!ent.Comp.RelayAccent) return; OnAccent(ent, ref args.Args); } protected virtual void OnStatusEffectRelayAccent(Entity ent, ref StatusEffectRelayedEvent args) { var ev = args.Args; OnAccent(ent, ref ev); args.Args = ev; } protected virtual void OnAccent(Entity ent, ref AccentGetEvent args) { args.Message = Accentuate(args.Message, ent); } /// /// Applies the accent transformation to the provided message. /// public virtual string Accentuate(string message, Entity? ent = null) { return message; } }