diff --git a/Content.Client/UserInterface/HumanoidProfileEditor.Random.cs b/Content.Client/UserInterface/HumanoidProfileEditor.Random.cs index d823c05b90..65f039fd08 100644 --- a/Content.Client/UserInterface/HumanoidProfileEditor.Random.cs +++ b/Content.Client/UserInterface/HumanoidProfileEditor.Random.cs @@ -15,22 +15,11 @@ namespace Content.Client.UserInterface private void RandomizeEverything() { - RandomizeSex(); - RandomizeAge(); - RandomizeName(); - RandomizeAppearance(); - } - - private void RandomizeSex() - { - SetSex(_random.Prob(0.5f) ? Sex.Male : Sex.Female); + Profile = HumanoidCharacterProfile.Random(); UpdateSexControls(); - } - - private void RandomizeAge() - { - SetAge(_random.Next(HumanoidCharacterProfile.MinimumAge, HumanoidCharacterProfile.MaximumAge)); UpdateAgeEdit(); + UpdateNameEdit(); + UpdateHairPickers(); } private void RandomizeName() @@ -42,33 +31,5 @@ namespace Content.Client.UserInterface SetName($"{firstName} {lastName}"); UpdateNameEdit(); } - - private void RandomizeAppearance() - { - var newHairStyle = _random.Pick(HairStyles.HairStylesMap.Keys.ToList()); - - var newFacialHairStyle = Profile.Sex == Sex.Female - ? HairStyles.DefaultFacialHairStyle - : _random.Pick(HairStyles.FacialHairStylesMap.Keys.ToList()); - - var newHairColor = _random.Pick(HairStyles.RealisticHairColors); - newHairColor = newHairColor - .WithRed(RandomizeColor(newHairColor.R)) - .WithGreen(RandomizeColor(newHairColor.G)) - .WithBlue(RandomizeColor(newHairColor.B)); - - Profile = Profile.WithCharacterAppearance( - Profile.Appearance - .WithHairStyleName(newHairStyle) - .WithFacialHairStyleName(newFacialHairStyle) - .WithHairColor(newHairColor) - .WithFacialHairColor(newHairColor)); - UpdateHairPickers(); - - float RandomizeColor(float channel) - { - return MathHelper.Clamp01(channel + _random.Next(-25, 25) / 100f); - } - } } } diff --git a/Content.Shared/Preferences/HumanoidCharacterAppearance.cs b/Content.Shared/Preferences/HumanoidCharacterAppearance.cs index 41f83c5476..694a500604 100644 --- a/Content.Shared/Preferences/HumanoidCharacterAppearance.cs +++ b/Content.Shared/Preferences/HumanoidCharacterAppearance.cs @@ -1,6 +1,10 @@ using System; +using System.Linq; using Content.Shared.Preferences.Appearance; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; using Robust.Shared.Maths; +using Robust.Shared.Random; using Robust.Shared.Serialization; namespace Content.Shared.Preferences @@ -73,6 +77,31 @@ namespace Content.Shared.Preferences ); } + public static HumanoidCharacterAppearance Random(Sex sex) + { + var random = IoCManager.Resolve(); + + var newHairStyle = random.Pick(HairStyles.HairStylesMap.Keys.ToList()); + + var newFacialHairStyle = sex == Sex.Female + ? HairStyles.DefaultFacialHairStyle + : random.Pick(HairStyles.FacialHairStylesMap.Keys.ToList()); + + var newHairColor = random.Pick(HairStyles.RealisticHairColors); + newHairColor = newHairColor + .WithRed(RandomizeColor(newHairColor.R)) + .WithGreen(RandomizeColor(newHairColor.G)) + .WithBlue(RandomizeColor(newHairColor.B)); + + // TODO: Add random eye and skin color + return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, Color.Black, Color.FromHex("#C0967F")); + + float RandomizeColor(float channel) + { + return MathHelper.Clamp01(channel + random.Next(-25, 25) / 100f); + } + } + public static HumanoidCharacterAppearance EnsureValid(HumanoidCharacterAppearance appearance) { string hairStyleName; diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index f730544c98..4601c33cdc 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -2,7 +2,11 @@ using System; using System.Collections.Generic; using System.Linq; using Content.Shared.Roles; +using Content.Shared.Text; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; using Robust.Shared.Prototypes; +using Robust.Shared.Random; using Robust.Shared.Serialization; namespace Content.Shared.Preferences @@ -49,7 +53,22 @@ namespace Content.Shared.Preferences public static HumanoidCharacterProfile Default() { - return new HumanoidCharacterProfile("John Doe", 18, Sex.Male, HumanoidCharacterAppearance.Default(), + return Random(); + } + + public static HumanoidCharacterProfile Random() + { + var random = IoCManager.Resolve(); + var sex = random.Prob(0.5f) ? Sex.Male : Sex.Female; + + var firstName = random.Pick(sex == Sex.Male + ? Names.MaleFirstNames + : Names.FemaleFirstNames); + var lastName = random.Pick(Names.LastNames); + var name = $"{firstName} {lastName}"; + var age = random.Next(MinimumAge, MaximumAge); + + return new HumanoidCharacterProfile(name, age, sex, HumanoidCharacterAppearance.Random(sex), new Dictionary { {SharedGameTicker.OverflowJob, JobPriority.High}