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}";
}
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
-using Robust.Shared.Prototypes;
+using Robust.Shared.Prototypes;
namespace Content.Shared.NameIdentifier;
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;
}
--- /dev/null
+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}
# 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
- type: nameIdentifierGroup
id: CargoTelepads
- prefix: TELE
+ format: name-identifier-format-telepad
minValue: 0
maxValue: 999