Skin color validation (#15140)
This commit is contained in:
@@ -217,23 +217,11 @@ namespace Content.Shared.Humanoid
|
||||
markingSet = new MarkingSet(appearance.Markings, speciesProto.MarkingPoints, markingManager, proto);
|
||||
markingSet.EnsureValid(markingManager);
|
||||
|
||||
switch (speciesProto.SkinColoration)
|
||||
if (!Humanoid.SkinColor.VerifySkinColor(speciesProto.SkinColoration, skinColor))
|
||||
{
|
||||
case HumanoidSkinColor.HumanToned:
|
||||
if (!Humanoid.SkinColor.VerifyHumanSkinTone(skinColor))
|
||||
{
|
||||
skinColor = Humanoid.SkinColor.ValidHumanSkinTone;
|
||||
skinColor = Humanoid.SkinColor.ValidSkinTone(speciesProto.SkinColoration, skinColor);
|
||||
}
|
||||
|
||||
break;
|
||||
case HumanoidSkinColor.TintedHues:
|
||||
if (!Humanoid.SkinColor.VerifyTintedHues(skinColor))
|
||||
{
|
||||
skinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(skinColor);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
markingSet.EnsureSpecies(species, skinColor, markingManager);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,16 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
||||
if (!Resolve(uid, ref humanoid))
|
||||
return;
|
||||
|
||||
if (!_prototypeManager.TryIndex<SpeciesPrototype>(humanoid.Species, out var species))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SkinColor.VerifySkinColor(species.SkinColoration, skinColor))
|
||||
{
|
||||
skinColor = SkinColor.ValidSkinTone(species.SkinColoration, skinColor);
|
||||
}
|
||||
|
||||
humanoid.SkinColor = skinColor;
|
||||
|
||||
if (sync)
|
||||
|
||||
@@ -133,6 +133,27 @@ public static class SkinColor
|
||||
// tinted hues just ensures saturation is always .1, or 10% saturation at all times
|
||||
return Color.ToHsv(color).Y != .1f;
|
||||
}
|
||||
|
||||
public static bool VerifySkinColor(HumanoidSkinColor type, Color color)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
HumanoidSkinColor.HumanToned => VerifyHumanSkinTone(color),
|
||||
HumanoidSkinColor.TintedHues => VerifyTintedHues(color),
|
||||
HumanoidSkinColor.Hues => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
public static Color ValidSkinTone(HumanoidSkinColor type, Color color)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
HumanoidSkinColor.HumanToned => ValidHumanSkinTone,
|
||||
HumanoidSkinColor.TintedHues => ValidTintedHuesSkinTone(color),
|
||||
_ => color
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum HumanoidSkinColor : byte
|
||||
|
||||
Reference in New Issue
Block a user