Display gender and age when examining humanoids (#11177)
This commit is contained in:
@@ -1,19 +1,26 @@
|
|||||||
using Content.Shared.Body.Part;
|
using Content.Shared.Body.Part;
|
||||||
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.CharacterAppearance.Components;
|
using Content.Shared.CharacterAppearance.Components;
|
||||||
using Content.Shared.Preferences;
|
using Content.Shared.Preferences;
|
||||||
|
using Content.Shared.IdentityManagement;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects.Components.Localization;
|
using Robust.Shared.GameObjects.Components.Localization;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Content.Shared.Species;
|
||||||
|
|
||||||
namespace Content.Shared.CharacterAppearance.Systems
|
namespace Content.Shared.CharacterAppearance.Systems
|
||||||
{
|
{
|
||||||
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentGetState>(OnAppearanceGetState);
|
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentGetState>(OnAppearanceGetState);
|
||||||
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentHandleState>(OnAppearanceHandleState);
|
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentHandleState>(OnAppearanceHandleState);
|
||||||
|
SubscribeLocalEvent<HumanoidAppearanceComponent, ExaminedEvent>(OnExamined);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile, HumanoidAppearanceComponent? appearance=null)
|
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);
|
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)
|
private void OnAppearanceGetState(EntityUid uid, HumanoidAppearanceComponent component, ref ComponentGetState args)
|
||||||
{
|
{
|
||||||
args.State = new HumanoidAppearanceComponentState(component.Appearance, component.Sex, component.Gender, component.Species, component.Age);
|
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;
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
humanoid-appearance-component-unknown-species = Person
|
||||||
|
humanoid-appearance-component-examine = { CAPITALIZE(SUBJECT($user)) } { CONJUGATE-BE($user) } { INDEFINITE($age) } { $age } { $species }.
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
name: Urist McHands
|
name: Urist McHands
|
||||||
parent: BaseMobHuman
|
parent: BaseMobHuman
|
||||||
id: MobHuman
|
id: MobHuman
|
||||||
description: A miserable pile of secrets.
|
|
||||||
components:
|
components:
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
canDisarm: true
|
canDisarm: true
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
name: Urisst' Mzhand
|
name: Urisst' Mzhand
|
||||||
parent: BaseMobReptilian
|
parent: BaseMobReptilian
|
||||||
id: MobReptilian
|
id: MobReptilian
|
||||||
description: A miserable pile of scales.
|
|
||||||
components:
|
components:
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
canDisarm: true
|
canDisarm: true
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
save: false
|
save: false
|
||||||
name: Urist McHands
|
name: Urist McHands
|
||||||
id: BaseMobOrganic
|
id: BaseMobOrganic
|
||||||
description: A miserable pile of secrets.
|
|
||||||
noSpawn: true
|
noSpawn: true
|
||||||
components:
|
components:
|
||||||
- type: RangedDamageSound
|
- type: RangedDamageSound
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
parent: BaseMobOrganic
|
parent: BaseMobOrganic
|
||||||
id: BaseMobDwarf
|
id: BaseMobDwarf
|
||||||
abstract: true
|
abstract: true
|
||||||
description: A miserable pile of secrets.
|
|
||||||
components:
|
components:
|
||||||
- type: Hunger
|
- type: Hunger
|
||||||
- type: Thirst
|
- type: Thirst
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
parent: BaseMobOrganic
|
parent: BaseMobOrganic
|
||||||
id: BaseMobHuman
|
id: BaseMobHuman
|
||||||
abstract: true
|
abstract: true
|
||||||
description: A miserable pile of secrets.
|
|
||||||
components:
|
components:
|
||||||
- type: Hunger
|
- type: Hunger
|
||||||
- type: Thirst
|
- type: Thirst
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
parent: BaseMobOrganic
|
parent: BaseMobOrganic
|
||||||
id: BaseMobReptilian
|
id: BaseMobReptilian
|
||||||
abstract: true
|
abstract: true
|
||||||
description: A miserable pile of scales.
|
|
||||||
components:
|
components:
|
||||||
- type: Hunger
|
- type: Hunger
|
||||||
- type: Thirst
|
- type: Thirst
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
parent: BaseMobOrganic
|
parent: BaseMobOrganic
|
||||||
id: BaseMobSkeletonPerson
|
id: BaseMobSkeletonPerson
|
||||||
abstract: true
|
abstract: true
|
||||||
description: A miserable pile of bones.
|
|
||||||
components:
|
components:
|
||||||
- type: Markings
|
- type: Markings
|
||||||
- type: Icon
|
- type: Icon
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
parent: BaseMobOrganic
|
parent: BaseMobOrganic
|
||||||
id: BaseMobSlimePerson
|
id: BaseMobSlimePerson
|
||||||
abstract: true
|
abstract: true
|
||||||
description: A miserable pile of slime.
|
|
||||||
components:
|
components:
|
||||||
- type: Hunger
|
- type: Hunger
|
||||||
- type: Thirst
|
- type: Thirst
|
||||||
|
|||||||
Reference in New Issue
Block a user