Humanoid patches (#11467)
* restores species/age on examine * makes the default human skin tone a little less green * ensures human skin tone verification is rounded to the nearest integer value, adds tests for ensuring all human skin tones are valid and that the default skin tone is valid
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Markings;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Tag;
|
||||
@@ -14,8 +16,8 @@ namespace Content.Server.Humanoid;
|
||||
|
||||
public sealed partial class HumanoidSystem : SharedHumanoidSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly MarkingManager _markingManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -23,6 +25,7 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
|
||||
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierMarkingSetMessage>(OnMarkingsSet);
|
||||
SubscribeLocalEvent<HumanoidComponent, HumanoidMarkingModifierBaseLayersSetMessage>(OnBaseLayersSet);
|
||||
SubscribeLocalEvent<HumanoidComponent, GetVerbsEvent<Verb>>(OnVerbsRequest);
|
||||
SubscribeLocalEvent<HumanoidComponent, ExaminedEvent>(OnExamined);
|
||||
}
|
||||
|
||||
private void Synchronize(EntityUid uid, HumanoidComponent? component = null)
|
||||
@@ -62,6 +65,15 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, HumanoidComponent 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)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a humanoid character profile directly onto this humanoid mob.
|
||||
/// </summary>
|
||||
@@ -464,6 +476,31 @@ public sealed partial class HumanoidSystem : SharedHumanoidSystem
|
||||
Synchronize(uid, humanoid);
|
||||
}
|
||||
|
||||
/// <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 EnsureDefaultMarkings(EntityUid uid, HumanoidComponent? humanoid)
|
||||
{
|
||||
if (!Resolve(uid, ref humanoid))
|
||||
|
||||
Reference in New Issue
Block a user