Random humanoid appearance (#7895)

This commit is contained in:
Kara
2022-05-02 13:50:56 -07:00
committed by GitHub
parent 291ad9c307
commit 930533cd94
5 changed files with 45 additions and 2 deletions

View File

@@ -83,6 +83,7 @@ namespace Content.Client.Entry
"DiseaseCarrier",
"StorageFill",
"Absorbent",
"RandomHumanoidAppearance",
"CableVis",
"BatterySelfRecharger",
"Puddle",

View File

@@ -0,0 +1,8 @@
namespace Content.Server.CharacterAppearance.Components;
[RegisterComponent]
public sealed class RandomHumanoidAppearanceComponent : Component
{
[DataField("randomizeName")]
public bool RandomizeName = true;
}

View File

@@ -0,0 +1,33 @@
using Content.Server.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Preferences;
namespace Content.Server.CharacterAppearance.Systems;
public sealed class RandomHumanoidAppearanceSystem : EntitySystem
{
[Dependency] private readonly SharedHumanoidAppearanceSystem _humanoidAppearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RandomHumanoidAppearanceComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, RandomHumanoidAppearanceComponent component, MapInitEvent args)
{
if (TryComp<HumanoidAppearanceComponent>(uid, out var appearance))
{
var profile = HumanoidCharacterProfile.Random();
_humanoidAppearance.UpdateFromProfile(uid, profile, appearance);
if (component.RandomizeName)
{
var meta = MetaData(uid);
meta.EntityName = profile.Name;
}
}
}
}

View File

@@ -18,10 +18,10 @@ namespace Content.Shared.CharacterAppearance.Systems
SubscribeLocalEvent<HumanoidAppearanceComponent, ComponentHandleState>(OnAppearanceHandleState);
}
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile)
public void UpdateFromProfile(EntityUid uid, ICharacterProfile profile, HumanoidAppearanceComponent? appearance=null)
{
var humanoid = (HumanoidCharacterProfile) profile;
UpdateAppearance(uid, humanoid.Appearance, humanoid.Sex, humanoid.Gender, humanoid.Species);
UpdateAppearance(uid, humanoid.Appearance, humanoid.Sex, humanoid.Gender, humanoid.Species, appearance);
}
// The magic mirror otherwise wouldn't work. (it directly modifies the component server-side)

View File

@@ -51,3 +51,4 @@
description: Inspect the station, jot down performance reviews for heads of staff, bug the Captain.
- type: UtilityAI
startingGear: CentcomGear
- type: RandomHumanoidAppearance