diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 9e03181b48..9f0ac3d086 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -83,6 +83,7 @@ namespace Content.Client.Entry "DiseaseCarrier", "StorageFill", "Absorbent", + "RandomHumanoidAppearance", "CableVis", "BatterySelfRecharger", "Puddle", diff --git a/Content.Server/CharacterAppearance/Components/RandomHumanoidAppearanceComponent.cs b/Content.Server/CharacterAppearance/Components/RandomHumanoidAppearanceComponent.cs new file mode 100644 index 0000000000..105032e546 --- /dev/null +++ b/Content.Server/CharacterAppearance/Components/RandomHumanoidAppearanceComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server.CharacterAppearance.Components; + +[RegisterComponent] +public sealed class RandomHumanoidAppearanceComponent : Component +{ + [DataField("randomizeName")] + public bool RandomizeName = true; +} diff --git a/Content.Server/CharacterAppearance/Systems/RandomHumanoidAppearanceSystem.cs b/Content.Server/CharacterAppearance/Systems/RandomHumanoidAppearanceSystem.cs new file mode 100644 index 0000000000..c7ca4fdbb5 --- /dev/null +++ b/Content.Server/CharacterAppearance/Systems/RandomHumanoidAppearanceSystem.cs @@ -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(OnMapInit); + } + + private void OnMapInit(EntityUid uid, RandomHumanoidAppearanceComponent component, MapInitEvent args) + { + if (TryComp(uid, out var appearance)) + { + var profile = HumanoidCharacterProfile.Random(); + _humanoidAppearance.UpdateFromProfile(uid, profile, appearance); + + if (component.RandomizeName) + { + var meta = MetaData(uid); + meta.EntityName = profile.Name; + } + } + } +} diff --git a/Content.Shared/CharacterAppearance/Systems/SharedHumanoidAppearanceSystem.cs b/Content.Shared/CharacterAppearance/Systems/SharedHumanoidAppearanceSystem.cs index df7491e922..a1fec9999e 100644 --- a/Content.Shared/CharacterAppearance/Systems/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/CharacterAppearance/Systems/SharedHumanoidAppearanceSystem.cs @@ -18,10 +18,10 @@ namespace Content.Shared.CharacterAppearance.Systems SubscribeLocalEvent(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) diff --git a/Resources/Prototypes/Entities/Mobs/Player/human.yml b/Resources/Prototypes/Entities/Mobs/Player/human.yml index f9a883dfcd..4decaa22d6 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/human.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/human.yml @@ -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