Display gender and age when examining humanoids (#11177)

This commit is contained in:
och-och
2022-09-11 17:45:39 +03:00
committed by GitHub
parent ca5962f388
commit 633c74d440
10 changed files with 43 additions and 8 deletions

View File

@@ -1,19 +1,26 @@
using Content.Shared.Body.Part;
using Content.Shared.Examine;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Preferences;
using Content.Shared.IdentityManagement;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects.Components.Localization;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;
using Content.Shared.Species;
namespace Content.Shared.CharacterAppearance.Systems
{
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentGetState>(OnAppearanceGetState);
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentHandleState>(OnAppearanceHandleState);
SubscribeLocalEvent<HumanoidAppearanceComponent, ExaminedEvent>(OnExamined);
}
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile, HumanoidAppearanceComponent? appearance=null)
@@ -69,6 +76,31 @@ namespace Content.Shared.CharacterAppearance.Systems
RaiseLocalEvent(uid, new ChangedHumanoidAppearanceEvent(component.Appearance, component.Sex, component.Gender, component.Species), true);
}
/// <summary>
/// Takes ID of the species prototype, returns UI-friendly name of the species.
/// </summary>
public string GetSpeciesRepresentation(string speciesId)
{
if (_prototypeManager.TryIndex<SpeciesPrototype>(speciesId, out var species))
{
return Loc.GetString(species.Name);
}
else
{
return Loc.GetString("humanoid-appearance-component-unknown-species");
}
}
public string GetAgeRepresentation(int age)
{
return age switch
{
<= 30 => Loc.GetString("identity-age-young"),
> 30 and <= 60 => Loc.GetString("identity-age-middle-aged"),
> 60 => Loc.GetString("identity-age-old")
};
}
private void OnAppearanceGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
{
args.State = new HumanoidAppearanceComponentState(component.Appearance, component.Sex, component.Gender, component.Species, component.Age);
@@ -144,5 +176,14 @@ namespace Content.Shared.CharacterAppearance.Systems
Species = species;
}
}
private void OnExamined(EntityUid uid, HumanoidAppearanceComponent component, ExaminedEvent args)
{
var identity = Identity.Entity(component.Owner, EntityManager);
var species = GetSpeciesRepresentation(component.Species).ToLower();
var age = GetAgeRepresentation(component.Age);
args.PushText(Loc.GetString("humanoid-appearance-component-examine", ("user", identity), ("age", age), ("species", species)));
}
}
}

View File

@@ -0,0 +1,2 @@
humanoid-appearance-component-unknown-species = Person
humanoid-appearance-component-examine = { CAPITALIZE(SUBJECT($user)) } { CONJUGATE-BE($user) } { INDEFINITE($age) } { $age } { $species }.

View File

@@ -3,7 +3,6 @@
name: Urist McHands
parent: BaseMobHuman
id: MobHuman
description: A miserable pile of secrets.
components:
- type: CombatMode
canDisarm: true

View File

@@ -3,7 +3,6 @@
name: Urisst' Mzhand
parent: BaseMobReptilian
id: MobReptilian
description: A miserable pile of scales.
components:
- type: CombatMode
canDisarm: true

View File

@@ -3,7 +3,6 @@
save: false
name: Urist McHands
id: BaseMobOrganic
description: A miserable pile of secrets.
noSpawn: true
components:
- type: RangedDamageSound

View File

@@ -4,7 +4,6 @@
parent: BaseMobOrganic
id: BaseMobDwarf
abstract: true
description: A miserable pile of secrets.
components:
- type: Hunger
- type: Thirst

View File

@@ -4,7 +4,6 @@
parent: BaseMobOrganic
id: BaseMobHuman
abstract: true
description: A miserable pile of secrets.
components:
- type: Hunger
- type: Thirst

View File

@@ -4,7 +4,6 @@
parent: BaseMobOrganic
id: BaseMobReptilian
abstract: true
description: A miserable pile of scales.
components:
- type: Hunger
- type: Thirst

View File

@@ -4,7 +4,6 @@
parent: BaseMobOrganic
id: BaseMobSkeletonPerson
abstract: true
description: A miserable pile of bones.
components:
- type: Markings
- type: Icon

View File

@@ -3,7 +3,6 @@
parent: BaseMobOrganic
id: BaseMobSlimePerson
abstract: true
description: A miserable pile of slime.
components:
- type: Hunger
- type: Thirst