From: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Date: Sun, 30 Nov 2025 10:52:13 +0000 (+0100)
Subject: predict name identifiers (#41605)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=58cdf0af4965934828bf4f261c7efeb6d55d4652;p=space-station-14.git
predict name identifiers (#41605)
---
diff --git a/Content.Client/NameIdentifier/NameIdentifierSystem.cs b/Content.Client/NameIdentifier/NameIdentifierSystem.cs
new file mode 100644
index 0000000000..c699ca6419
--- /dev/null
+++ b/Content.Client/NameIdentifier/NameIdentifierSystem.cs
@@ -0,0 +1,5 @@
+using Content.Shared.NameIdentifier;
+
+namespace Content.Client.NameIdentifier;
+
+public sealed class NameIdentifierSystem : SharedNameIdentifierSystem;
diff --git a/Content.Server/NameIdentifier/NameIdentifierSystem.cs b/Content.Server/NameIdentifier/NameIdentifierSystem.cs
index 27e25a4b4f..9f199c4599 100644
--- a/Content.Server/NameIdentifier/NameIdentifierSystem.cs
+++ b/Content.Server/NameIdentifier/NameIdentifierSystem.cs
@@ -7,10 +7,7 @@ using Robust.Shared.Random;
namespace Content.Server.NameIdentifier;
-///
-/// Handles unique name identifiers for entities e.g. `monkey (MK-912)`
-///
-public sealed class NameIdentifierSystem : EntitySystem
+public sealed class NameIdentifierSystem : SharedNameIdentifierSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
@@ -28,7 +25,6 @@ public sealed class NameIdentifierSystem : EntitySystem
SubscribeLocalEvent(OnMapInit);
SubscribeLocalEvent(OnComponentShutdown);
- SubscribeLocalEvent(OnRefreshNameModifiers);
SubscribeLocalEvent(CleanupIds);
SubscribeLocalEvent(OnReloadPrototypes);
@@ -122,24 +118,6 @@ public sealed class NameIdentifierSystem : EntitySystem
_nameModifier.RefreshNameModifiers(ent.Owner);
}
- private void OnRefreshNameModifiers(Entity ent, ref RefreshNameModifiersEvent args)
- {
- if (ent.Comp.Group is null)
- return;
-
- // Don't apply the modifier if the component is being removed
- if (ent.Comp.LifeStage > ComponentLifeStage.Running)
- return;
-
- if (!_prototypeManager.Resolve(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()
{
EnsureIds();
diff --git a/Content.Shared/NameIdentifier/SharedNameIdentifierSystem.cs b/Content.Shared/NameIdentifier/SharedNameIdentifierSystem.cs
new file mode 100644
index 0000000000..05a6e43c2a
--- /dev/null
+++ b/Content.Shared/NameIdentifier/SharedNameIdentifierSystem.cs
@@ -0,0 +1,37 @@
+using Content.Shared.NameModifier.EntitySystems;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.NameIdentifier;
+
+///
+/// Handles unique name identifiers for entities e.g. `monkey (MK-912)`
+///
+public abstract class SharedNameIdentifierSystem : EntitySystem
+{
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnRefreshNameModifiers);
+ }
+
+ private void OnRefreshNameModifiers(Entity ent, ref RefreshNameModifiersEvent args)
+ {
+ if (ent.Comp.Group is null)
+ return;
+
+ // Don't apply the modifier if the component is being removed
+ if (ent.Comp.LifeStage > ComponentLifeStage.Running)
+ return;
+
+ if (!_prototypeManager.Resolve(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));
+ }
+}