]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
make name identifier prefix LocId (#39035)
authorlzk <124214523+lzk228@users.noreply.github.com>
Fri, 18 Jul 2025 18:59:49 +0000 (20:59 +0200)
committerGitHub <noreply@github.com>
Fri, 18 Jul 2025 18:59:49 +0000 (21:59 +0300)
Content.Server/NameIdentifier/NameIdentifierSystem.cs
Content.Shared/NameIdentifier/NameIdentifierGroupPrototype.cs
Resources/Locale/en-US/name-identifier.ftl [new file with mode: 0644]
Resources/Prototypes/name_identifier_groups.yml

index 1e5ed67a63bbe7a430ad1cdfdf96d285aba8774f..c0b9beaa9aaa4253ea75b846fa3dd097963c8f80 100644 (file)
@@ -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
index e3dceca4895420379073fcefe7816818ed33da06..933902e222f5f21b9f5887faca1ee20c88fc18bd 100644 (file)
@@ -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!;
 
     /// <summary>
-    ///     Should the identifier become the full name, or just append?
+    /// Should the identifier become the full name, or just append?
     /// </summary>
-    [DataField("fullName")]
+    [DataField]
     public bool FullName = false;
 
-    [DataField("prefix")]
-    public string? Prefix;
+    /// <summary>
+    /// 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").
+    /// </summary>
+    [DataField]
+    public LocId? Format;
 
-    [DataField("maxValue")]
+    /// <summary>
+    /// The maximal value appearing in an identifier.
+    /// </summary>
+    [DataField]
     public int MaxValue = 1000;
 
-    [DataField("minValue")]
+    /// <summary>
+    /// The minimal value appearing in an identifier.
+    /// </summary>
+    [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 (file)
index 0000000..9fa72bc
--- /dev/null
@@ -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}
index ab8c9f90acbc912367405f58e82f6bd5a33fc009..9777e84243f299a93883e929414510a2bfe99773 100644 (file)
@@ -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