From ffbc813179291286dda2dcfdfd58648f909ab1c2 Mon Sep 17 00:00:00 2001
From: lzk <124214523+lzk228@users.noreply.github.com>
Date: Fri, 18 Jul 2025 20:59:49 +0200
Subject: [PATCH] make name identifier prefix LocId (#39035)
---
.../NameIdentifier/NameIdentifierSystem.cs | 8 +++----
.../NameIdentifierGroupPrototype.cs | 24 +++++++++++++------
Resources/Locale/en-US/name-identifier.ftl | 8 +++++++
.../Prototypes/name_identifier_groups.yml | 16 ++++++-------
4 files changed, 37 insertions(+), 19 deletions(-)
create mode 100644 Resources/Locale/en-US/name-identifier.ftl
diff --git a/Content.Server/NameIdentifier/NameIdentifierSystem.cs b/Content.Server/NameIdentifier/NameIdentifierSystem.cs
index 1e5ed67a63..c0b9beaa9a 100644
--- a/Content.Server/NameIdentifier/NameIdentifierSystem.cs
+++ b/Content.Server/NameIdentifier/NameIdentifierSystem.cs
@@ -82,8 +82,8 @@ public sealed class NameIdentifierSystem : EntitySystem
randomVal = set[^1];
set.RemoveAt(set.Count - 1);
- return proto.Prefix is not null
- ? $"{proto.Prefix}-{randomVal}"
+ return proto.Format is not null
+ ? Loc.GetString(proto.Format, ("number", randomVal))
: $"{randomVal}";
}
@@ -104,8 +104,8 @@ public sealed class NameIdentifierSystem : EntitySystem
ids.Remove(ent.Comp.Identifier))
{
id = ent.Comp.Identifier;
- uniqueName = group.Prefix is not null
- ? $"{group.Prefix}-{id}"
+ uniqueName = group.Format is not null
+ ? Loc.GetString(group.Format, ("number", id))
: $"{id}";
}
else
diff --git a/Content.Shared/NameIdentifier/NameIdentifierGroupPrototype.cs b/Content.Shared/NameIdentifier/NameIdentifierGroupPrototype.cs
index e3dceca489..933902e222 100644
--- a/Content.Shared/NameIdentifier/NameIdentifierGroupPrototype.cs
+++ b/Content.Shared/NameIdentifier/NameIdentifierGroupPrototype.cs
@@ -1,4 +1,4 @@
-using Robust.Shared.Prototypes;
+using Robust.Shared.Prototypes;
namespace Content.Shared.NameIdentifier;
@@ -9,17 +9,27 @@ public sealed partial class NameIdentifierGroupPrototype : IPrototype
public string ID { get; private set; } = default!;
///
- /// Should the identifier become the full name, or just append?
+ /// Should the identifier become the full name, or just append?
///
- [DataField("fullName")]
+ [DataField]
public bool FullName = false;
- [DataField("prefix")]
- public string? Prefix;
+ ///
+ /// Optional format identifier. If set, the name will be formatted using it (e.g., "MK-500").
+ /// If not set, only the numeric part will be used (e.g., "500").
+ ///
+ [DataField]
+ public LocId? Format;
- [DataField("maxValue")]
+ ///
+ /// The maximal value appearing in an identifier.
+ ///
+ [DataField]
public int MaxValue = 1000;
- [DataField("minValue")]
+ ///
+ /// The minimal value appearing in an identifier.
+ ///
+ [DataField]
public int MinValue = 0;
}
diff --git a/Resources/Locale/en-US/name-identifier.ftl b/Resources/Locale/en-US/name-identifier.ftl
new file mode 100644
index 0000000000..9fa72bc9e1
--- /dev/null
+++ b/Resources/Locale/en-US/name-identifier.ftl
@@ -0,0 +1,8 @@
+name-identifier-format-monkey = MK-{$number}
+name-identifier-format-kobold = KB-{$number}
+name-identifier-format-holoparasite = HOLO-{$number}
+name-identifier-format-mmi = MMI-{$number}
+name-identifier-format-positronic-brain = PB-{$number}
+name-identifier-format-silicon = Si-{$number}
+name-identifier-format-station-ai = AI-{$number}
+name-identifier-format-telepad = TELE-{$number}
diff --git a/Resources/Prototypes/name_identifier_groups.yml b/Resources/Prototypes/name_identifier_groups.yml
index ab8c9f90ac..9777e84243 100644
--- a/Resources/Prototypes/name_identifier_groups.yml
+++ b/Resources/Prototypes/name_identifier_groups.yml
@@ -1,37 +1,37 @@
# Non-fungible apes, anyone?
- type: nameIdentifierGroup
id: Monkey
- prefix: MK
+ format: name-identifier-format-monkey
- type: nameIdentifierGroup
id: Kobold
- prefix: KB
+ format: name-identifier-format-kobold
- type: nameIdentifierGroup
id: Holoparasite
- prefix: HOLO
+ format: name-identifier-format-holoparasite
- type: nameIdentifierGroup
id: MMI
- prefix: MMI
+ format: name-identifier-format-mmi
minValue: 100
maxValue: 999
- type: nameIdentifierGroup
id: PositronicBrain
- prefix: PB
+ format: name-identifier-format-positronic-brain
minValue: 10
maxValue: 99
- type: nameIdentifierGroup
id: Silicon
- prefix: Si
+ format: name-identifier-format-silicon
minValue: 1000
maxValue: 9999
- type: nameIdentifierGroup
id: StationAi
- prefix: AI
+ format: name-identifier-format-station-ai
minValue: 100
maxValue: 999
@@ -51,6 +51,6 @@
- type: nameIdentifierGroup
id: CargoTelepads
- prefix: TELE
+ format: name-identifier-format-telepad
minValue: 0
maxValue: 999