Use race specific identity age to build text (#19789)
* Use race specific identity age text * Use variables * Simplify
This commit is contained in:
@@ -1,14 +1,17 @@
|
|||||||
using Content.Server.Access.Systems;
|
using Content.Server.Access.Systems;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Server.Humanoid;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Humanoid;
|
using Content.Shared.Humanoid;
|
||||||
|
using Content.Shared.Humanoid.Prototypes;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.IdentityManagement.Components;
|
using Content.Shared.IdentityManagement.Components;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects.Components.Localization;
|
using Robust.Shared.GameObjects.Components.Localization;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.IdentityManagement;
|
namespace Content.Server.IdentityManagement;
|
||||||
|
|
||||||
@@ -20,6 +23,7 @@ public class IdentitySystem : SharedIdentitySystem
|
|||||||
[Dependency] private readonly IdCardSystem _idCard = default!;
|
[Dependency] private readonly IdCardSystem _idCard = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLog = default!;
|
[Dependency] private readonly IAdminLogManager _adminLog = default!;
|
||||||
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
||||||
|
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
|
||||||
|
|
||||||
private HashSet<EntityUid> _queuedIdentityUpdates = new();
|
private HashSet<EntityUid> _queuedIdentityUpdates = new();
|
||||||
|
|
||||||
@@ -123,17 +127,20 @@ public class IdentitySystem : SharedIdentitySystem
|
|||||||
{
|
{
|
||||||
int age = 18;
|
int age = 18;
|
||||||
Gender gender = Gender.Epicene;
|
Gender gender = Gender.Epicene;
|
||||||
|
string species = SharedHumanoidAppearanceSystem.DefaultSpecies;
|
||||||
|
|
||||||
// Always use their actual age and gender, since that can't really be changed by an ID.
|
// Always use their actual age and gender, since that can't really be changed by an ID.
|
||||||
if (Resolve(target, ref appearance, false))
|
if (Resolve(target, ref appearance, false))
|
||||||
{
|
{
|
||||||
gender = appearance.Gender;
|
gender = appearance.Gender;
|
||||||
age = appearance.Age;
|
age = appearance.Age;
|
||||||
|
species = appearance.Species;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ageString = _humanoid.GetAgeRepresentation(species, age);
|
||||||
var trueName = Name(target);
|
var trueName = Name(target);
|
||||||
if (!Resolve(target, ref inventory, false))
|
if (!Resolve(target, ref inventory, false))
|
||||||
return new(trueName, age, gender, string.Empty);
|
return new(trueName, gender, ageString, string.Empty);
|
||||||
|
|
||||||
string? presumedJob = null;
|
string? presumedJob = null;
|
||||||
string? presumedName = null;
|
string? presumedName = null;
|
||||||
@@ -146,7 +153,7 @@ public class IdentitySystem : SharedIdentitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it didn't find a job, that's fine.
|
// If it didn't find a job, that's fine.
|
||||||
return new(trueName, age, gender, presumedName, presumedJob);
|
return new(trueName, gender, ageString, presumedName, presumedJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Robust.Shared.Containers;
|
using Content.Shared.Humanoid.Prototypes;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
|
|
||||||
namespace Content.Shared.IdentityManagement.Components;
|
namespace Content.Shared.IdentityManagement.Components;
|
||||||
@@ -24,18 +25,20 @@ public sealed partial class IdentityComponent : Component
|
|||||||
public sealed class IdentityRepresentation
|
public sealed class IdentityRepresentation
|
||||||
{
|
{
|
||||||
public string TrueName;
|
public string TrueName;
|
||||||
public int TrueAge;
|
|
||||||
public Gender TrueGender;
|
public Gender TrueGender;
|
||||||
|
|
||||||
|
public string AgeString;
|
||||||
|
|
||||||
public string? PresumedName;
|
public string? PresumedName;
|
||||||
public string? PresumedJob;
|
public string? PresumedJob;
|
||||||
|
|
||||||
public IdentityRepresentation(string trueName, int trueAge, Gender trueGender, string? presumedName=null, string? presumedJob=null)
|
public IdentityRepresentation(string trueName, Gender trueGender, string ageString, string? presumedName=null, string? presumedJob=null)
|
||||||
{
|
{
|
||||||
TrueName = trueName;
|
TrueName = trueName;
|
||||||
TrueAge = trueAge;
|
|
||||||
TrueGender = trueGender;
|
TrueGender = trueGender;
|
||||||
|
|
||||||
|
AgeString = ageString;
|
||||||
|
|
||||||
PresumedJob = presumedJob;
|
PresumedJob = presumedJob;
|
||||||
PresumedName = presumedName;
|
PresumedName = presumedName;
|
||||||
}
|
}
|
||||||
@@ -54,13 +57,6 @@ public sealed class IdentityRepresentation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ToStringUnknown()
|
public string ToStringUnknown()
|
||||||
{
|
{
|
||||||
var ageString = TrueAge switch
|
|
||||||
{
|
|
||||||
<= 30 => Loc.GetString("identity-age-young"),
|
|
||||||
> 30 and <= 60 => Loc.GetString("identity-age-middle-aged"),
|
|
||||||
> 60 => Loc.GetString("identity-age-old")
|
|
||||||
};
|
|
||||||
|
|
||||||
var genderString = TrueGender switch
|
var genderString = TrueGender switch
|
||||||
{
|
{
|
||||||
Gender.Female => Loc.GetString("identity-gender-feminine"),
|
Gender.Female => Loc.GetString("identity-gender-feminine"),
|
||||||
@@ -70,7 +66,7 @@ public sealed class IdentityRepresentation
|
|||||||
|
|
||||||
// i.e. 'young assistant man' or 'old cargo technician person' or 'middle-aged captain'
|
// i.e. 'young assistant man' or 'old cargo technician person' or 'middle-aged captain'
|
||||||
return PresumedJob is null
|
return PresumedJob is null
|
||||||
? $"{ageString} {genderString}"
|
? $"{AgeString} {genderString}"
|
||||||
: $"{ageString} {PresumedJob} {genderString}";
|
: $"{AgeString} {PresumedJob} {genderString}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user