Implemented random character creation (#548)
* Implemented random character creation * Pick from a list and apply a bit of randomness instead * Rename SetInitialData, unselect list entries properly
This commit is contained in:
committed by
Pieter-Jan Briers
parent
5af5a02e31
commit
46ce6bf45e
67
Content.Client/UserInterface/HumanoidProfileEditor.Random.cs
Normal file
67
Content.Client/UserInterface/HumanoidProfileEditor.Random.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Preferences.Appearance;
|
||||
using Content.Shared.Text;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public partial class HumanoidProfileEditor
|
||||
{
|
||||
private readonly IRobustRandom _random;
|
||||
|
||||
private void RandomizeEverything()
|
||||
{
|
||||
RandomizeSex();
|
||||
RandomizeAge();
|
||||
RandomizeName();
|
||||
RandomizeAppearance();
|
||||
}
|
||||
|
||||
private void RandomizeSex()
|
||||
{
|
||||
SetSex(_random.Prob(0.5f) ? Sex.Male : Sex.Female);
|
||||
UpdateSexControls();
|
||||
}
|
||||
|
||||
private void RandomizeAge()
|
||||
{
|
||||
SetAge(_random.Next(HumanoidCharacterProfile.MinimumAge, HumanoidCharacterProfile.MaximumAge));
|
||||
UpdateAgeEdit();
|
||||
}
|
||||
|
||||
private void RandomizeName()
|
||||
{
|
||||
var firstName = _random.Pick(Profile.Sex == Sex.Male
|
||||
? Names.MaleFirstNames
|
||||
: Names.FemaleFirstNames);
|
||||
var lastName = _random.Pick(Names.LastNames);
|
||||
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(newHairColor.R + _random.Next(-25, 25) / 100f)
|
||||
.WithGreen(newHairColor.G + _random.Next(-25, 25) / 100f)
|
||||
.WithBlue(newHairColor.B + _random.Next(-25, 25) / 100f);
|
||||
|
||||
Profile = Profile.WithCharacterAppearance(
|
||||
Profile.Appearance
|
||||
.WithHairStyleName(newHairStyle)
|
||||
.WithFacialHairStyleName(newFacialHairStyle)
|
||||
.WithHairColor(newHairColor)
|
||||
.WithFacialHairColor(newHairColor));
|
||||
UpdateHairPickers();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user