diff --git a/Content.Client/Silicons/Borgs/BorgMenu.xaml.cs b/Content.Client/Silicons/Borgs/BorgMenu.xaml.cs index b8f0e69c02..007a0cc5cb 100644 --- a/Content.Client/Silicons/Borgs/BorgMenu.xaml.cs +++ b/Content.Client/Silicons/Borgs/BorgMenu.xaml.cs @@ -1,6 +1,7 @@ using Content.Client.Stylesheets; using Content.Client.UserInterface.Controls; using Content.Shared.NameIdentifier; +using Content.Shared.NameModifier.EntitySystems; using Content.Shared.Preferences; using Content.Shared.Silicons.Borgs; using Content.Shared.Silicons.Borgs.Components; @@ -15,6 +16,7 @@ namespace Content.Client.Silicons.Borgs; public sealed partial class BorgMenu : FancyWindow { [Dependency] private readonly IEntityManager _entity = default!; + private readonly NameModifierSystem _nameModifier; public Action? BrainButtonPressed; public Action? EjectBatteryButtonPressed; @@ -32,6 +34,8 @@ public sealed partial class BorgMenu : FancyWindow RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); + _nameModifier = _entity.System(); + _lastValidName = NameLineEdit.Text; EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke(); @@ -54,9 +58,7 @@ public sealed partial class BorgMenu : FancyWindow NameIdentifierLabel.Visible = true; NameIdentifierLabel.Text = nameIdentifierComponent.FullIdentifier; - var fullName = _entity.GetComponent(Entity).EntityName; - var name = fullName.Substring(0, fullName.Length - nameIdentifierComponent.FullIdentifier.Length - 1); - NameLineEdit.Text = name; + NameLineEdit.Text = _nameModifier.GetBaseName(entity); } else { diff --git a/Content.Server/NameIdentifier/NameIdentifierSystem.cs b/Content.Server/NameIdentifier/NameIdentifierSystem.cs index 273e9407fd..0a9f87557a 100644 --- a/Content.Server/NameIdentifier/NameIdentifierSystem.cs +++ b/Content.Server/NameIdentifier/NameIdentifierSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.GameTicking; using Content.Shared.NameIdentifier; +using Content.Shared.NameModifier.EntitySystems; using Robust.Shared.Collections; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -13,7 +14,7 @@ public sealed class NameIdentifierSystem : EntitySystem { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!; - [Dependency] private readonly MetaDataSystem _metaData = default!; + [Dependency] private readonly NameModifierSystem _nameModifier = default!; /// /// Free IDs available per . @@ -27,6 +28,7 @@ public sealed class NameIdentifierSystem : EntitySystem SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnComponentShutdown); + SubscribeLocalEvent(OnRefreshNameModifiers); SubscribeLocalEvent(CleanupIds); SubscribeLocalEvent(OnReloadPrototypes); @@ -44,6 +46,7 @@ public sealed class NameIdentifierSystem : EntitySystem ids[randomIndex] = component.Identifier; ids.Add(random); } + _nameModifier.RefreshNameModifiers(uid); } /// @@ -108,12 +111,22 @@ public sealed class NameIdentifierSystem : EntitySystem ? uniqueName : $"({uniqueName})"; - var meta = MetaData(uid); - // "DR-1234" as opposed to "drone (DR-1234)" - _metaData.SetEntityName(uid, group.FullName - ? uniqueName - : $"{meta.EntityName} ({uniqueName})", meta); Dirty(uid, component); + _nameModifier.RefreshNameModifiers(uid); + } + + private void OnRefreshNameModifiers(Entity ent, ref RefreshNameModifiersEvent args) + { + // Don't apply the modifier if the component is being removed + if (ent.Comp.LifeStage > ComponentLifeStage.Running) + return; + + if (!_prototypeManager.TryIndex(ent.Comp.Group, out var group)) + return; + var format = group.FullName ? "name-identifier-format-full" : "name-identifier-format-append"; + // We apply the modifier with a low priority to keep it near the base name + // "Beep (Si-4562) the zombie" instead of "Beep the zombie (Si-4562)" + args.AddModifier(format, -10, ("identifier", ent.Comp.FullIdentifier)); } private void InitialSetupPrototypes() diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs index 40c2c3bf33..9f9977cddc 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs @@ -62,8 +62,6 @@ public sealed partial class BorgSystem } var name = args.Name.Trim(); - if (TryComp(uid, out var identifier)) - name = $"{name} {identifier.FullIdentifier}"; var metaData = MetaData(uid); diff --git a/Resources/Locale/en-US/name-identifier/name-identifier.ftl b/Resources/Locale/en-US/name-identifier/name-identifier.ftl new file mode 100644 index 0000000000..e0c05e51d3 --- /dev/null +++ b/Resources/Locale/en-US/name-identifier/name-identifier.ftl @@ -0,0 +1,2 @@ +name-identifier-format-append = {$baseName} {$identifier} +name-identifier-format-full = {$identifier}