diff --git a/Content.Server/Speech/Components/AccentWearerNameClothingComponent.cs b/Content.Server/Speech/Components/AccentWearerNameClothingComponent.cs new file mode 100644 index 0000000000..288eaa8dcb --- /dev/null +++ b/Content.Server/Speech/Components/AccentWearerNameClothingComponent.cs @@ -0,0 +1,10 @@ +using Content.Server.Speech.EntitySystems; + +namespace Content.Server.Speech.Components; + +/// +/// Applies any accent components on this item to the name of the wearer while worn. +/// +[RegisterComponent] +[Access(typeof(AccentWearerNameClothingSystem))] +public sealed partial class AccentWearerNameClothingComponent : Component; diff --git a/Content.Server/Speech/EntitySystems/AccentWearerNameClothingSystem.cs b/Content.Server/Speech/EntitySystems/AccentWearerNameClothingSystem.cs new file mode 100644 index 0000000000..fc381c5998 --- /dev/null +++ b/Content.Server/Speech/EntitySystems/AccentWearerNameClothingSystem.cs @@ -0,0 +1,39 @@ +using Content.Server.Speech.Components; +using Content.Shared.Clothing; +using Content.Shared.Inventory; +using Content.Shared.NameModifier.EntitySystems; + +namespace Content.Server.Speech.EntitySystems; + +/// +public sealed class AccentWearerNameClothingSystem : EntitySystem +{ + [Dependency] private readonly NameModifierSystem _nameMod = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnGotEquipped); + SubscribeLocalEvent(OnGotUnequipped); + SubscribeLocalEvent>(OnRefreshNameModifiers); + } + + private void OnGotEquipped(Entity ent, ref ClothingGotEquippedEvent args) + { + _nameMod.RefreshNameModifiers(args.Wearer); + } + + private void OnGotUnequipped(Entity ent, ref ClothingGotUnequippedEvent args) + { + _nameMod.RefreshNameModifiers(args.Wearer); + } + + private void OnRefreshNameModifiers(Entity ent, ref InventoryRelayedEvent args) + { + var ev = new AccentGetEvent(ent, args.Args.BaseName); + RaiseLocalEvent(ent, ev); + // Use a negative priority since we're going to bulldoze any earlier changes + args.Args.AddModifier("comp-accent-wearer-name-clothing-format", -1, ("accentedName", ev.Message)); + } +} diff --git a/Resources/Locale/en-US/speech/accent-wearer-name-clothing.ftl b/Resources/Locale/en-US/speech/accent-wearer-name-clothing.ftl new file mode 100644 index 0000000000..49b0fb31aa --- /dev/null +++ b/Resources/Locale/en-US/speech/accent-wearer-name-clothing.ftl @@ -0,0 +1 @@ +comp-accent-wearer-name-clothing-format = {$accentedName} diff --git a/Resources/Prototypes/Entities/Clothing/Head/hats.yml b/Resources/Prototypes/Entities/Clothing/Head/hats.yml index 2d2b2a353e..8cdabb4e14 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hats.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hats.yml @@ -489,6 +489,8 @@ - type: Appearance - type: AddAccentClothing accent: RussianAccent + - type: RussianAccent + - type: AccentWearerNameClothing - type: Foldable canFoldInsideContainer: true - type: FoldableClothing