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,12 +5,12 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid namespace Content.Shared.Humanoid;
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance
{ {
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance
{
public HumanoidCharacterAppearance(string hairStyleId, public HumanoidCharacterAppearance(string hairStyleId,
Color hairColor, Color hairColor,
string facialHairStyleId, string facialHairStyleId,
@@ -154,25 +154,18 @@ namespace Content.Shared.Humanoid
var skinType = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species).SkinColoration; 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) switch (skinType)
{ {
case HumanoidSkinColor.HumanToned: case HumanoidSkinColor.HumanToned:
var tone = random.Next(0, 100); var tone = Math.Round(Humanoid.SkinColor.HumanSkinToneFromColor(newSkinColor));
newSkinColor = Humanoid.SkinColor.HumanSkinTone(tone); newSkinColor = Humanoid.SkinColor.HumanSkinTone((int)tone);
break; break;
case HumanoidSkinColor.Hues: 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; break;
} case HumanoidSkinColor.TintedHues:
if (skinType == HumanoidSkinColor.TintedHues)
{
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor); newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor);
break;
} }
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ()); return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ());
@@ -248,5 +241,4 @@ namespace Content.Shared.Humanoid
if (!Markings.SequenceEqual(other.Markings)) return false; if (!Markings.SequenceEqual(other.Markings)) return false;
return true; return true;
} }
}
} }