make name identifier prefix LocId (#39035)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.NameIdentifier;
|
||||
|
||||
@@ -11,15 +11,25 @@ public sealed partial class NameIdentifierGroupPrototype : IPrototype
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
|
||||
8
Resources/Locale/en-US/name-identifier.ftl
Normal file
8
Resources/Locale/en-US/name-identifier.ftl
Normal file
@@ -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}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user