From: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Date: Mon, 16 Jun 2025 07:50:17 +0000 (-0700) Subject: Revert "Randomized Markings" (#38345) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d8b70a3887d70b94f3baa144884b8c52442a1614;p=space-station-14.git Revert "Randomized Markings" (#38345) --- diff --git a/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs b/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs index 35ac458695..05bebea075 100644 --- a/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs +++ b/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs @@ -126,220 +126,52 @@ public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance, { var random = IoCManager.Resolve(); var markingManager = IoCManager.Resolve(); + var hairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.Hair, species).Keys.ToList(); + var facialHairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.FacialHair, species).Keys.ToList(); - var newFacialHairStyle = HairStyles.DefaultFacialHairStyle; - var newHairStyle = HairStyles.DefaultHairStyle; - List newMarkings = []; + var newHairStyle = hairStyles.Count > 0 + ? random.Pick(hairStyles) + : HairStyles.DefaultHairStyle; - // grab a completely random color. - var baseColor = new Color(random.NextFloat(1), random.NextFloat(1), random.NextFloat(1), 1); + var newFacialHairStyle = facialHairStyles.Count == 0 || sex == Sex.Female + ? HairStyles.DefaultFacialHairStyle + : random.Pick(facialHairStyles); - // create a new color palette based on BaseColor. roll to determine what type of palette it is. - // personally I think this should be weighted, but I can't be bothered to implement that. - List colorPalette = []; - switch (random.Next(3)) - { - case 0: - colorPalette = GetSplitComplementaries(baseColor); - break; - case 1: - colorPalette = GetTriadicComplementaries(baseColor); - break; - case 2: - colorPalette = GetOneComplementary(baseColor); - break; - } + var newHairColor = random.Pick(HairStyles.RealisticHairColors); + newHairColor = newHairColor + .WithRed(RandomizeColor(newHairColor.R)) + .WithGreen(RandomizeColor(newHairColor.G)) + .WithBlue(RandomizeColor(newHairColor.B)); - // grab the species skin coloration type. - var skinType = IoCManager.Resolve().Index(species).SkinColoration; + // TODO: Add random markings - // declare some defaults. ensures that the hair and eyes on hues-colored species don't match the skin or one another. - var newSkinColor = colorPalette[0]; - var newHairColor = colorPalette[1]; - var newEyeColor = colorPalette[2]; + var newEyeColor = random.Pick(RealisticEyeColors); - // now we do some color logic. + var skinType = IoCManager.Resolve().Index(species).SkinColoration; + + var newSkinColor = new Color(random.NextFloat(1), random.NextFloat(1), random.NextFloat(1), 1); switch (skinType) { - // if the species is HumanToned: case HumanoidSkinColor.HumanToned: - // quantize the randomized skin color to the nearest acceptable HumanToned color. var tone = Math.Round(Humanoid.SkinColor.HumanSkinToneFromColor(newSkinColor)); newSkinColor = Humanoid.SkinColor.HumanSkinTone((int)tone); - - // pick a random realistic hair color from the list and randomize it juuuuust a little bit. - newHairColor = random.Pick(HairStyles.RealisticHairColors); - newHairColor = newHairColor - .WithRed(RandomizeColor(newHairColor.R)) - .WithGreen(RandomizeColor(newHairColor.G)) - .WithBlue(RandomizeColor(newHairColor.B)); - - // and pick a random realistic eye color from the list. - newEyeColor = random.Pick(RealisticEyeColors); - - // we're also going to crush the other colors down to the skin's luminosity so markings don't appear too bright on darker skin. - colorPalette[1] = SquashToSkinLuminosity(newSkinColor, colorPalette[1]); - colorPalette[2] = SquashToSkinLuminosity(newSkinColor, colorPalette[2]); break; - - // if the species is Hues toned: it's fine the way it is. case HumanoidSkinColor.Hues: break; - - // if the species is TintedHues toned: tint them hues. case HumanoidSkinColor.TintedHues: newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor); - - // we're also going to crush the other colors down to valid TintedHues skin colors. - colorPalette[1] = Humanoid.SkinColor.ValidTintedHuesSkinTone(colorPalette[1]); - colorPalette[2] = Humanoid.SkinColor.ValidTintedHuesSkinTone(colorPalette[2]); break; - - // if the species is VoxFeathers toned: confine the skin color to vox limits. Bright colors are otherwise fine, so leave the marking colors alone. case HumanoidSkinColor.VoxFeathers: newSkinColor = Humanoid.SkinColor.ProportionalVoxColor(newSkinColor); break; } - // now we loop through every extant marking category, - foreach (var category in Enum.GetValues()) - { - // grab a list of markings in that category for that species, - var markings = markingManager.MarkingsByCategoryAndSpecies(category, species).Keys.ToList(); - var markingProtos = markingManager.MarkingsByCategoryAndSpecies(category, species).Values.ToList(); - - // if it's facial hair, there are entries in the category, and the character is not female, assign a random one. else bald - if (category == MarkingCategories.FacialHair) - { - newFacialHairStyle = markings.Count == 0 || sex == Sex.Female ? HairStyles.DefaultFacialHairStyle : random.Pick(markings); - } - - // if it's hair, and there are hair styles, roll one. else bald - else if (category == MarkingCategories.Hair) - { - newHairStyle = markings.Count > 0 ? random.Pick(markings) : HairStyles.DefaultHairStyle; - } - - // for every other category, - else if (markings.Count > 0) - { - // roll a die. currently a 1 in 3 chance per category, except Tails, which are 1 in 2 (because of the effect they have on the silhouettes of spiders and moths.) - int diceRoll; - if (category == MarkingCategories.Tail) - diceRoll = random.Next(2); - else - diceRoll = random.Next(3); - - if (diceRoll == 0) - { - MarkingPrototype? lastMarking = null; - - // roll to see how many markings from that category will be added. currently a maximum of 2. - var loops = random.Next(2) + 1; - - // add a marking (loops) times - for (var i = 0; i < loops; i++) - { - // pick a random marking from the list - var protoToAdd = random.Pick(markingProtos); - var markingToAdd = protoToAdd.AsMarking(); - Color markingColor; - - // prevent duplicates: - if (lastMarking != null && lastMarking == protoToAdd) - continue; - - // set gauze to white. - // side note, I really hate that gauze isn't its own category. please fix that so that i can make this not suck as much. - // or, like, give it its own color rules. or something. - if (markingToAdd.MarkingId.Contains("gauze", StringComparison.OrdinalIgnoreCase)) - { - markingToAdd.SetColor(Color.White); - newMarkings.Add(markingToAdd); - lastMarking = protoToAdd; - continue; - } - - // select a random color from our two secondary colors. if our marking is a Tail, add the skin color as well, otherwise lizards always look a little odd. - // this will also make moths and spiders look less interesting on average, but I don't want a hardcoded exception for lizards. - if (category == MarkingCategories.Tail) - markingColor = random.Pick(colorPalette); - else - markingColor = random.Pick(colorPalette.Skip(0).ToList()); - - // set the marking to that color - markingToAdd.SetColor(markingColor); - - // otherwise, add it to the final list. - newMarkings.Add(markingToAdd); - lastMarking = protoToAdd; - } - } - } - } - - // at the end of all that, we should have new values for each of these, so we set the character appearance to these new values. - return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, newMarkings); + return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ()); - // helper functions: float RandomizeColor(float channel) { return MathHelper.Clamp01(channel + random.Next(-25, 25) / 100f); } - - List GetComplementaryColors(Color color, double angle) - { - var hsl = Color.ToHsl(color); - - var hVal = hsl.X + angle; - hVal = hVal >= 0.360 ? hVal - 0.360 : hVal; - var positiveHSL = new Vector4((float)hVal, hsl.Y, hsl.Z, hsl.W); - - var hVal1 = hsl.X - angle; - hVal1 = hVal1 <= 0 ? hVal1 + 0.360 : hVal1; - var negativeHSL = new Vector4((float)hVal1, hsl.Y, hsl.Z, hsl.W); - - var c0 = Color.FromHsl(positiveHSL); - var c1 = Color.FromHsl(negativeHSL); - - var palette = new List { color, c0, c1 }; - return palette; - } - - // return a list of triadic complementary colors - List GetTriadicComplementaries(Color color) - { - return GetComplementaryColors(color, 0.120); - } - - // return a list of split complementary colors - List GetSplitComplementaries(Color color) - { - return GetComplementaryColors(color, 0.150); - } - - // return a list containing the base color and two copies of a single complemenary color - List GetOneComplementary(Color color) - { - return GetComplementaryColors(color, 0.180); - } - - Color SquashToSkinLuminosity(Color skinColor, Color toSquash) - { - var skinColorHSL = Color.ToHsl(skinColor); - var toSquashHSL = Color.ToHsl(toSquash); - - // check if the skin color is as dark as or darker than the marking color: - if (toSquashHSL.Z <= skinColorHSL.Z) - { - // if it is, don't fuck with it - return toSquash; - } - - // otherwise, create a new color with the H, S, and A of toSquash, but the L of skinColor - var newColor = new Vector4(toSquashHSL.X, toSquashHSL.Y, skinColorHSL.Z, toSquashHSL.W); - return Color.FromHsl(newColor); - } } public static Color ClampColor(Color color)