Cleanup in HumanoidCharacterAppearance (#26974)

* namespace

* Tidy up the code for selecting random humanoid color
This commit is contained in:
Errant
2024-04-18 05:27:11 +02:00
committed by GitHub
parent 24a0298f76
commit 7120e8736a

View File

@@ -5,8 +5,8 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid
{
namespace Content.Shared.Humanoid;
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance
@@ -154,25 +154,18 @@ namespace Content.Shared.Humanoid
var skinType = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species).SkinColoration;
var newSkinColor = Humanoid.SkinColor.ValidHumanSkinTone;
var newSkinColor = new Color(random.NextFloat(1), random.NextFloat(1), random.NextFloat(1), 1);
switch (skinType)
{
case HumanoidSkinColor.HumanToned:
var tone = random.Next(0, 100);
newSkinColor = Humanoid.SkinColor.HumanSkinTone(tone);
var tone = Math.Round(Humanoid.SkinColor.HumanSkinToneFromColor(newSkinColor));
newSkinColor = Humanoid.SkinColor.HumanSkinTone((int)tone);
break;
case HumanoidSkinColor.Hues:
case HumanoidSkinColor.TintedHues:
var rbyte = random.NextByte();
var gbyte = random.NextByte();
var bbyte = random.NextByte();
newSkinColor = new Color(rbyte, gbyte, bbyte);
break;
}
if (skinType == HumanoidSkinColor.TintedHues)
{
case HumanoidSkinColor.TintedHues:
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor);
break;
}
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ());
@@ -249,4 +242,3 @@ namespace Content.Shared.Humanoid
return true;
}
}
}