Humanoid fixes (#11538)
* humanoid sexmorph sprite restoration can't believe i broke sex/gender AGAIN * fixes default species appearances with no profile, tweaks randomization to no longer randomize species * A * fixes an oops #11494
This commit is contained in:
@@ -97,6 +97,28 @@ namespace Content.Shared.Humanoid
|
||||
);
|
||||
}
|
||||
|
||||
public static HumanoidCharacterAppearance DefaultWithSpecies(string species)
|
||||
{
|
||||
var speciesPrototype = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species);
|
||||
var skinColor = speciesPrototype.SkinColoration switch
|
||||
{
|
||||
HumanoidSkinColor.HumanToned => Humanoid.SkinColor.HumanSkinTone(speciesPrototype.DefaultHumanSkinTone),
|
||||
HumanoidSkinColor.Hues => speciesPrototype.DefaultSkinTone,
|
||||
HumanoidSkinColor.TintedHues => Humanoid.SkinColor.TintedHues(speciesPrototype.DefaultSkinTone),
|
||||
_ => Humanoid.SkinColor.ValidHumanSkinTone
|
||||
};
|
||||
|
||||
return new(
|
||||
HairStyles.DefaultHairStyle,
|
||||
Color.Black,
|
||||
HairStyles.DefaultFacialHairStyle,
|
||||
Color.Black,
|
||||
Color.Black,
|
||||
skinColor,
|
||||
new ()
|
||||
);
|
||||
}
|
||||
|
||||
private static IReadOnlyList<Color> RealisticEyeColors = new List<Color>
|
||||
{
|
||||
Color.Brown,
|
||||
|
||||
@@ -12,11 +12,12 @@ public enum HumanoidVisualizerKey
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class HumanoidVisualizerData : ICloneable
|
||||
{
|
||||
public HumanoidVisualizerData(string species, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayerInfo, Color skinColor, List<HumanoidVisualLayers> layerVisibility, List<Marking> markings)
|
||||
public HumanoidVisualizerData(string species, Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayerInfo, Color skinColor, Sex sex, List<HumanoidVisualLayers> layerVisibility, List<Marking> markings)
|
||||
{
|
||||
Species = species;
|
||||
CustomBaseLayerInfo = customBaseLayerInfo;
|
||||
SkinColor = skinColor;
|
||||
Sex = sex;
|
||||
LayerVisibility = layerVisibility;
|
||||
Markings = markings;
|
||||
}
|
||||
@@ -24,11 +25,12 @@ public sealed class HumanoidVisualizerData : ICloneable
|
||||
public string Species { get; }
|
||||
public Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> CustomBaseLayerInfo { get; }
|
||||
public Color SkinColor { get; }
|
||||
public Sex Sex { get; }
|
||||
public List<HumanoidVisualLayers> LayerVisibility { get; }
|
||||
public List<Marking> Markings { get; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new HumanoidVisualizerData(Species, new(CustomBaseLayerInfo), SkinColor, new(LayerVisibility), new(Markings));
|
||||
return new HumanoidVisualizerData(Species, new(CustomBaseLayerInfo), SkinColor, Sex, new(LayerVisibility), new(Markings));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,19 @@ public sealed class SpeciesPrototype : IPrototype
|
||||
[DataField("sprites")]
|
||||
public string SpriteSet { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Default skin tone for this species. This applies for non-human skin tones.
|
||||
/// </summary>
|
||||
[DataField("defaultSkinTone")]
|
||||
public Color DefaultSkinTone { get; } = Color.White;
|
||||
|
||||
/// <summary>
|
||||
/// Default human skin tone for this species. This applies for human skin tones.
|
||||
/// See <see cref="SkinColor.HumanSkinTone"/> for the valid range of skin tones.
|
||||
/// </summary>
|
||||
[DataField("defaultHumanSkinTone")]
|
||||
public int DefaultHumanSkinTone { get; } = 20;
|
||||
|
||||
/// <summary>
|
||||
/// The limit of body markings that you can place on this species.
|
||||
/// </summary>
|
||||
|
||||
@@ -24,10 +24,11 @@ public abstract class SharedHumanoidSystem : EntitySystem
|
||||
string species,
|
||||
Dictionary<HumanoidVisualLayers, CustomBaseLayerInfo> customBaseLayer,
|
||||
Color skinColor,
|
||||
Sex sex,
|
||||
List<HumanoidVisualLayers> visLayers,
|
||||
List<Marking> markings)
|
||||
{
|
||||
var data = new HumanoidVisualizerData(species, customBaseLayer, skinColor, visLayers, markings);
|
||||
var data = new HumanoidVisualizerData(species, customBaseLayer, skinColor, sex, visLayers, markings);
|
||||
|
||||
// Locally raise an event for this, because there might be some systems interested
|
||||
// in this.
|
||||
|
||||
@@ -15,11 +15,10 @@ public static class SkinColor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a human skin tone based on a scale of 0 to 100.
|
||||
/// Get a human skin tone based on a scale of 0 to 100. The value is clamped between 0 and 100.
|
||||
/// </summary>
|
||||
/// <param name="tone">Skin tone. Valid range is 0 to 100, inclusive. 0 is gold/yellowish, 100 is dark brown.</param>
|
||||
/// <returns>A human skin tone.</returns>
|
||||
/// <exception cref="ArgumentException">Exception if the value is under 0 or over 100.</exception>
|
||||
public static Color HumanSkinTone(int tone)
|
||||
{
|
||||
// 0 - 100, 0 being gold/yellowish and 100 being dark
|
||||
@@ -31,10 +30,7 @@ public static class SkinColor
|
||||
// 20 is 25 - 20 - 100
|
||||
// 100 is 25 - 100 - 20
|
||||
|
||||
if (tone < 0 || tone > 100)
|
||||
{
|
||||
throw new ArgumentException("Skin tone value was under 0 or over 100.");
|
||||
}
|
||||
tone = Math.Clamp(tone, 0, 100);
|
||||
|
||||
var rangeOffset = tone - 20;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user