Random humanoid appearance (#7895)
This commit is contained in:
@@ -83,6 +83,7 @@ namespace Content.Client.Entry
|
||||
"DiseaseCarrier",
|
||||
"StorageFill",
|
||||
"Absorbent",
|
||||
"RandomHumanoidAppearance",
|
||||
"CableVis",
|
||||
"BatterySelfRecharger",
|
||||
"Puddle",
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Server.CharacterAppearance.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class RandomHumanoidAppearanceComponent : Component
|
||||
{
|
||||
[DataField("randomizeName")]
|
||||
public bool RandomizeName = true;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user