mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* initial visual nubody * oops overlay * im so pheeming rn * conversion... * tests * comeback of the underwear * oops eyes * blabbl * zeds * yaml linted * search and visible count constraints * reordering * preserve previously selected markings colors * fix test * some ui niceties * ordering * make DB changes backwards-compatible/downgrade-friendly * fix things again * fix migration * vulpkanin markings limit increase * wrapping * code cleanup and more code cleanup and more code cleanup and more code cleanup and * fix slop ports * better sampling API * make filter work + use the method i made for its intended purpose * fix test fails real quick * magic mirror cleanup, remove TODO * don't 0-init the organ profile data * remove deltastates --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> # Conflicts: # Content.Server/Humanoid/Components/RandomHumanoidAppearanceComponent.cs # Content.Server/Humanoid/Systems/RandomHumanoidAppearanceSystem.cs # Conflicts: # Resources/Prototypes/Species/diona.yml # Conflicts: # Content.Server/Zombies/ZombieSystem.Transform.cs
84 lines
2.8 KiB
C#
84 lines
2.8 KiB
C#
using Content.Shared.Examine;
|
|
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.IdentityManagement;
|
|
using Content.Shared.Preferences;
|
|
using Robust.Shared.GameObjects.Components.Localization;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Humanoid;
|
|
|
|
public sealed class HumanoidProfileSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
[Dependency] private readonly GrammarSystem _grammar = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<HumanoidProfileComponent, ExaminedEvent>(OnExamined);
|
|
}
|
|
|
|
public void ApplyProfileTo(Entity<HumanoidProfileComponent?> ent, HumanoidCharacterProfile profile)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp))
|
|
return;
|
|
|
|
ent.Comp.Gender = profile.Gender;
|
|
ent.Comp.Age = profile.Age;
|
|
ent.Comp.Species = profile.Species;
|
|
ent.Comp.Sex = profile.Sex;
|
|
Dirty(ent);
|
|
|
|
if (TryComp<GrammarComponent>(ent, out var grammar))
|
|
{
|
|
_grammar.SetGender((ent, grammar), profile.Gender);
|
|
}
|
|
}
|
|
|
|
private void OnExamined(Entity<HumanoidProfileComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
var identity = Identity.Entity(ent, EntityManager);
|
|
var species = GetSpeciesRepresentation(ent.Comp.Species).ToLower();
|
|
var age = GetAgeRepresentation(ent.Comp.Species, ent.Comp.Age);
|
|
|
|
args.PushText(Loc.GetString("humanoid-appearance-component-examine", ("user", identity), ("age", age), ("species", species)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes ID of the species prototype, returns UI-friendly name of the species.
|
|
/// </summary>
|
|
public string GetSpeciesRepresentation(ProtoId<SpeciesPrototype> species)
|
|
{
|
|
if (_prototype.TryIndex(species, out var speciesPrototype))
|
|
return Loc.GetString(speciesPrototype.Name);
|
|
|
|
Log.Error("Tried to get representation of unknown species: {speciesId}");
|
|
return Loc.GetString("humanoid-appearance-component-unknown-species");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Takes ID of the species prototype and an age, returns an approximate description
|
|
/// </summary>
|
|
public string GetAgeRepresentation(ProtoId<SpeciesPrototype> species, int age)
|
|
{
|
|
if (!_prototype.TryIndex(species, out var speciesPrototype))
|
|
{
|
|
Log.Error("Tried to get age representation of species that couldn't be indexed: " + species);
|
|
return Loc.GetString("identity-age-young");
|
|
}
|
|
|
|
if (age < speciesPrototype.YoungAge)
|
|
{
|
|
return Loc.GetString("identity-age-young");
|
|
}
|
|
|
|
if (age < speciesPrototype.OldAge)
|
|
{
|
|
return Loc.GetString("identity-age-middle-aged");
|
|
}
|
|
|
|
return Loc.GetString("identity-age-old");
|
|
}
|
|
}
|