Use race specific identity age to build text (#19789)

* Use race specific identity age text

* Use variables

* Simplify
This commit is contained in:
Morb
2023-09-03 21:01:21 +03:00
committed by GitHub
parent fa0c5ff030
commit a268c890ed
2 changed files with 18 additions and 15 deletions

View File

@@ -1,14 +1,17 @@
using Content.Server.Access.Systems;
using Content.Server.Administration.Logs;
using Content.Server.Humanoid;
using Content.Shared.Database;
using Content.Shared.Hands;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.IdentityManagement;
using Content.Shared.IdentityManagement.Components;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.Prototypes;
namespace Content.Server.IdentityManagement;
@@ -20,6 +23,7 @@ public class IdentitySystem : SharedIdentitySystem
[Dependency] private readonly IdCardSystem _idCard = default!;
[Dependency] private readonly IAdminLogManager _adminLog = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
private HashSet<EntityUid> _queuedIdentityUpdates = new();
@@ -123,17 +127,20 @@ public class IdentitySystem : SharedIdentitySystem
{
int age = 18;
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.
if (Resolve(target, ref appearance, false))
{
gender = appearance.Gender;
age = appearance.Age;
species = appearance.Species;
}
var ageString = _humanoid.GetAgeRepresentation(species, age);
var trueName = Name(target);
if (!Resolve(target, ref inventory, false))
return new(trueName, age, gender, string.Empty);
return new(trueName, gender, ageString, string.Empty);
string? presumedJob = null;
string? presumedName = null;
@@ -146,7 +153,7 @@ public class IdentitySystem : SharedIdentitySystem
}
// 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

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Containers;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Containers;
using Robust.Shared.Enums;
namespace Content.Shared.IdentityManagement.Components;
@@ -24,18 +25,20 @@ public sealed partial class IdentityComponent : Component
public sealed class IdentityRepresentation
{
public string TrueName;
public int TrueAge;
public Gender TrueGender;
public string AgeString;
public string? PresumedName;
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;
TrueAge = trueAge;
TrueGender = trueGender;
AgeString = ageString;
PresumedJob = presumedJob;
PresumedName = presumedName;
}
@@ -54,13 +57,6 @@ public sealed class IdentityRepresentation
/// </summary>
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
{
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'
return PresumedJob is null
? $"{ageString} {genderString}"
: $"{ageString} {PresumedJob} {genderString}";
? $"{AgeString} {genderString}"
: $"{AgeString} {PresumedJob} {genderString}";
}
}