Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moth RGB 2: The electric boogaloo #184

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,8 @@ private void OnSkinColorOnValueChanged()

var skin = _prototypeManager.Index<SpeciesPrototype>(Profile.Species).SkinColoration;

var skinColor = _prototypeManager.Index<SpeciesPrototype>(Profile.Species).DefaultSkinTone;

switch (skin)
{
case HumanoidSkinColor.HumanToned:
Expand Down Expand Up @@ -671,14 +673,20 @@ private void OnSkinColorOnValueChanged()
break;
}
case HumanoidSkinColor.TintedHues:
case HumanoidSkinColor.TintedHuesSkin: // DeltaV - Tone blending
{
if (!_rgbSkinColorContainer.Visible)
{
_skinColor.Visible = false;
_rgbSkinColorContainer.Visible = true;
}

var color = SkinColor.TintedHues(_rgbSkinColorSelector.Color);
var color = skin switch // DeltaV - Tone blending
{
HumanoidSkinColor.TintedHues => SkinColor.TintedHues(_rgbSkinColorSelector.Color),
HumanoidSkinColor.TintedHuesSkin => SkinColor.TintedHuesSkin(_rgbSkinColorSelector.Color, skinColor),
_ => Color.White
};

CMarkings.CurrentSkinColor = color;
Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color));
Expand Down
14 changes: 14 additions & 0 deletions Content.Shared/Humanoid/HumanoidCharacterAppearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public static HumanoidCharacterAppearance DefaultWithSpecies(string species)
HumanoidSkinColor.HumanToned => Humanoid.SkinColor.HumanSkinTone(speciesPrototype.DefaultHumanSkinTone),
HumanoidSkinColor.Hues => speciesPrototype.DefaultSkinTone,
HumanoidSkinColor.TintedHues => Humanoid.SkinColor.TintedHues(speciesPrototype.DefaultSkinTone),
// DeltaV - Blended tint for moths
HumanoidSkinColor.TintedHuesSkin => Humanoid.SkinColor.TintedHuesSkin(speciesPrototype.DefaultSkinTone, speciesPrototype.DefaultSkinTone),
_ => Humanoid.SkinColor.ValidHumanSkinTone
};

Expand Down Expand Up @@ -153,6 +155,7 @@ public static HumanoidCharacterAppearance Random(string species, Sex sex)
var newEyeColor = random.Pick(RealisticEyeColors);

var skinType = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species).SkinColoration;
var skinTone = IoCManager.Resolve<IPrototypeManager>().Index<SpeciesPrototype>(species).DefaultSkinTone; // DeltaV, required for tone blending

var newSkinColor = Humanoid.SkinColor.ValidHumanSkinTone;
switch (skinType)
Expand All @@ -168,13 +171,24 @@ public static HumanoidCharacterAppearance Random(string species, Sex sex)
var bbyte = random.NextByte();
newSkinColor = new Color(rbyte, gbyte, bbyte);
break;
case HumanoidSkinColor.TintedHuesSkin: // DeltaV, tone blending
rbyte = random.NextByte();
gbyte = random.NextByte();
bbyte = random.NextByte();
newSkinColor = new Color(rbyte, gbyte, bbyte);
break;
}

if (skinType == HumanoidSkinColor.TintedHues)
{
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor);
}

if (skinType == HumanoidSkinColor.TintedHuesSkin) // DeltaV, tone blending
{
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(skinTone, newSkinColor);
}

return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ());

float RandomizeColor(float channel)
Expand Down
34 changes: 32 additions & 2 deletions Content.Shared/Humanoid/SkinColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public static class SkinColor
/// </summary>
/// <param name="color">The color to validate</param>
/// <returns>Validated tinted hue skin tone</returns>
public static Color ValidTintedHuesSkinTone(Color color)
public static Color ValidTintedHuesSkinTone(Color color, Color? skinTone = null)
{
return TintedHues(color);
return skinTone != null ? TintedHuesSkin(color, skinTone.Value) : TintedHues(color);
}

/// <summary>
Expand Down Expand Up @@ -127,6 +127,33 @@ public static Color TintedHues(Color color)
return Color.FromHsv(newColor);
}

/// <summary>
/// DeltaV - Convert a color to the 'tinted hues' skin tone type, and blend it into skinColor
/// </summary>
/// <param name="color">Color to convert</param>
/// <returns>Tinted hue color</returns>
public static Color TintedHuesSkin(Color color, Color skinColor, float blendFactor = 0.2f)
{
var colorHsv = Color.ToHsv(color);
var skinHsv = Color.ToHsv(skinColor);

colorHsv = new Vector4(
skinHsv.X + (colorHsv.X - skinHsv.X) * blendFactor,
skinHsv.Y + (colorHsv.Y - skinHsv.Y) * blendFactor,
skinHsv.Z + (colorHsv.Z - skinHsv.Z) * blendFactor,
skinHsv.W
);

colorHsv = new Vector4(
Math.Clamp(colorHsv.X, 0f, 360f),
Math.Clamp(colorHsv.Y, 0f, 1f),
Math.Clamp(colorHsv.Z, 0f, 1f),
colorHsv.W
);

return Color.FromHsv(colorHsv);
}

/// <summary>
/// Verify if this color is a valid tinted hue color type, or not.
/// </summary>
Expand All @@ -144,6 +171,7 @@ public static bool VerifySkinColor(HumanoidSkinColor type, Color color)
{
HumanoidSkinColor.HumanToned => VerifyHumanSkinTone(color),
HumanoidSkinColor.TintedHues => VerifyTintedHues(color),
HumanoidSkinColor.TintedHuesSkin => VerifyTintedHues(color), // DeltaV - Tone blending
HumanoidSkinColor.Hues => true,
_ => false,
};
Expand All @@ -155,6 +183,7 @@ public static Color ValidSkinTone(HumanoidSkinColor type, Color color)
{
HumanoidSkinColor.HumanToned => ValidHumanSkinTone,
HumanoidSkinColor.TintedHues => ValidTintedHuesSkinTone(color),
HumanoidSkinColor.TintedHuesSkin => ValidTintedHuesSkinTone(color), // DeltaV - Tone blending
_ => color
};
}
Expand All @@ -165,4 +194,5 @@ public enum HumanoidSkinColor : byte
HumanToned,
Hues,
TintedHues, //This gives a color tint to a humanoid's skin (10% saturation with full hue range).
TintedHuesSkin, // DeltaV - Default TintedHues assumes the texture will have the proper skin color, but moths dont
}
2 changes: 1 addition & 1 deletion Resources/Prototypes/Species/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
defaultSkinTone: "#ffda93"
markingLimits: MobMothMarkingLimits
dollPrototype: MobMothDummy
skinColoration: Hues
skinColoration: TintedHuesSkin # DeltaV - No rgb moths, literally 1849
maleFirstNames: names_moth_first_male
femaleFirstNames: names_moth_first_female
lastNames: names_moth_last
Expand Down
Loading