Files
wwdpublic/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs
SX-7 ff3595de9e Tajara (#1647)
# Description

~~On user end Felinids are removed and replaced with Tajara, mostly
inspired by the ParadiseStation sprites.~~

~~Most things from Felinids are ported over, either being untouched (in
which case they're left in the nyanotrasen directory), or somewhat
modified and copied to tajara directories. This is done because both
shadowkin and humans reference these files quite a bit, so we don't want
to break anything forwards/backwards,~~

~~Under the hood, felinid components are untouched, just simply set to
`abstract: true` and `roundstart: false`, once again to prevent any
breakage.~~

There's been like 50 changes all the ways, but basically, felinids are
staying, tajara get a few languages, they also are more "specialized"
than felinids due to big upsides and downsides (funny :)

---

# TODO

- [X] Add tajara
~~- [X] Hide felinids~~
~~- [x] Analyze and find now-orphaned felinid
protorypes/textures/references and remove them (optional)~~
- [x] Fix graphical bugs (if any)
- [x] Ensure the code structure is compliant with repo practices

---

<details><summary><h1>Media</h1></summary>
<p>

In captain attire

![{3169C46E-BABB-466F-BD75-D8A00D8F9105}](https://github.com/user-attachments/assets/74a7c43f-9d5d-440f-9c18-f1eb386ad3d7)
Testing emotes and languages

![{7EE18197-E788-46BF-9DA3-97B0718A2F0B}](https://github.com/user-attachments/assets/74dd9c17-92a2-4760-99f8-1bb893fa969d)
Emotes still working, same with hairballs

![{346EB863-EF92-4D82-8E72-409437372DC3}](https://github.com/user-attachments/assets/91b61aae-d460-4373-a0ba-79cbd64f8ec4)
Few character selector pictures
- The previously shown off tajaran

![{559C39A8-5333-4787-A3B7-2F882EB6B5E2}](https://github.com/user-attachments/assets/38d77c48-caa2-461f-858a-a6b1a235cc0f)
- Markingless male body

![{9D762061-C1F8-40A5-9F14-5809E803820C}](https://github.com/user-attachments/assets/719c18ba-0230-4b17-9166-fdd15cb67526)

![{98AFAEF1-D49A-4951-A18E-5E55ACC05A26}](https://github.com/user-attachments/assets/6f848c0a-9a1e-4aed-aeb7-0bbf7c1dab62)
- Markingless female body

![{8F42252C-DDC4-43FD-8B8F-BFF0FBD971CD}](https://github.com/user-attachments/assets/92ea11bc-2ddc-4569-b166-0380b34ee946)

![{EE2B152D-97AD-4C39-B51E-8D89E4C4B097}](https://github.com/user-attachments/assets/c6f3a8ee-20be-486a-bea8-b862cf2ea12e)
- Traits are updated, as is the case with other texts

![{6F1E0309-7262-48BA-ABF6-C2048E087437}](https://github.com/user-attachments/assets/778ede7d-3069-4b81-b09d-32aadb6c6b76)
~~- And a neon colored specimen to show off some markings~~ No longer
the case, fur hue is clamped to some reasonable colors

![{381F7D38-1ABE-4434-8F29-95908E8F1A4B}](https://github.com/user-attachments/assets/1ef52004-db37-4127-a113-0b5640087cc1)

</p>
</details>

---

# Changelog

🆑
- add: Added Tajara and related content

---------

Signed-off-by: SX-7 <92227810+SX-7@users.noreply.github.com>
Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
(cherry picked from commit b7660b95566c8e138cb458a3d70732c1d3ea4602)
2025-01-29 20:19:56 +03:00

295 lines
11 KiB
C#

using System.Linq;
using Content.Shared.Humanoid.Markings;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
namespace Content.Shared.Humanoid;
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance, IEquatable<HumanoidCharacterAppearance>
{
[DataField("hair")]
public string HairStyleId { get; set; } = HairStyles.DefaultHairStyle;
[DataField]
public Color HairColor { get; set; } = Color.Black;
[DataField("facialHair")]
public string FacialHairStyleId { get; set; } = HairStyles.DefaultFacialHairStyle;
[DataField]
public Color FacialHairColor { get; set; } = Color.Black;
[DataField]
public Color EyeColor { get; private set; }
[DataField]
public Color SkinColor { get; set; }
[DataField]
public List<Marking> Markings { get; private set; } = new();
public HumanoidCharacterAppearance(string hairStyleId,
Color hairColor,
string facialHairStyleId,
Color facialHairColor,
Color eyeColor,
Color skinColor,
List<Marking> markings)
{
HairStyleId = hairStyleId;
HairColor = ClampColor(hairColor);
FacialHairStyleId = facialHairStyleId;
FacialHairColor = ClampColor(facialHairColor);
EyeColor = ClampColor(eyeColor);
SkinColor = ClampColor(skinColor);
Markings = markings;
}
public HumanoidCharacterAppearance(HumanoidCharacterAppearance other)
: this(
other.HairStyleId,
other.HairColor,
other.FacialHairStyleId,
other.FacialHairColor,
other.EyeColor,
other.SkinColor,
new(other.Markings))
{
}
public HumanoidCharacterAppearance WithHairStyleName(string newName)
{
return new(newName, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor, Markings);
}
public HumanoidCharacterAppearance WithHairColor(Color newColor)
{
return new(HairStyleId, newColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor, Markings);
}
public HumanoidCharacterAppearance WithFacialHairStyleName(string newName)
{
return new(HairStyleId, HairColor, newName, FacialHairColor, EyeColor, SkinColor, Markings);
}
public HumanoidCharacterAppearance WithFacialHairColor(Color newColor)
{
return new(HairStyleId, HairColor, FacialHairStyleId, newColor, EyeColor, SkinColor, Markings);
}
public HumanoidCharacterAppearance WithEyeColor(Color newColor)
{
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, newColor, SkinColor, Markings);
}
public HumanoidCharacterAppearance WithSkinColor(Color newColor)
{
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, newColor, Markings);
}
public HumanoidCharacterAppearance WithMarkings(List<Marking> newMarkings)
{
return new(HairStyleId, HairColor, FacialHairStyleId, FacialHairColor, EyeColor, SkinColor, newMarkings);
}
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),
HumanoidSkinColor.VoxFeathers => Humanoid.SkinColor.ClosestVoxColor(speciesPrototype.DefaultSkinTone),
HumanoidSkinColor.AnimalFur => Humanoid.SkinColor.ClosestAnimalFurColor(speciesPrototype.DefaultSkinTone), // Einstein Engines - Tajaran
HumanoidSkinColor.TintedHuesSkin => Humanoid.SkinColor.TintedHuesSkin(speciesPrototype.DefaultSkinTone, 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,
Color.Gray,
Color.Azure,
Color.SteelBlue,
Color.Black
};
public static HumanoidCharacterAppearance Random(string species, Sex sex)
{
var random = IoCManager.Resolve<IRobustRandom>();
var markingManager = IoCManager.Resolve<MarkingManager>();
var hairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.Hair, species).Keys.ToList();
var facialHairStyles = markingManager.MarkingsByCategoryAndSpecies(MarkingCategories.FacialHair, species).Keys.ToList();
var newHairStyle = hairStyles.Count > 0
? random.Pick(hairStyles)
: HairStyles.DefaultHairStyle;
var newFacialHairStyle = facialHairStyles.Count == 0 || sex == Sex.Female
? HairStyles.DefaultFacialHairStyle
: random.Pick(facialHairStyles);
var newHairColor = random.Pick(HairStyles.RealisticHairColors);
newHairColor = newHairColor
.WithRed(RandomizeColor(newHairColor.R))
.WithGreen(RandomizeColor(newHairColor.G))
.WithBlue(RandomizeColor(newHairColor.B));
// TODO: Add random markings
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 = new Color(random.NextFloat(1), random.NextFloat(1), random.NextFloat(1), 1);
switch (skinType)
{
case HumanoidSkinColor.HumanToned:
var tone = Math.Round(Humanoid.SkinColor.HumanSkinToneFromColor(newSkinColor));
newSkinColor = Humanoid.SkinColor.HumanSkinTone((int)tone);
break;
case HumanoidSkinColor.Hues:
break;
case HumanoidSkinColor.TintedHues:
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(newSkinColor);
break;
case HumanoidSkinColor.TintedHuesSkin:
newSkinColor = Humanoid.SkinColor.ValidTintedHuesSkinTone(skinTone, newSkinColor);
break;
case HumanoidSkinColor.VoxFeathers:
newSkinColor = Humanoid.SkinColor.ProportionalVoxColor(newSkinColor);
break;
case HumanoidSkinColor.AnimalFur: // Einstein Engines - Tajaran
newSkinColor = Humanoid.SkinColor.ProportionalAnimalFurColor(newSkinColor);
break;
}
return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ());
float RandomizeColor(float channel)
{
return MathHelper.Clamp01(channel + random.Next(-25, 25) / 100f);
}
}
public static Color ClampColor(Color color)
{
return new(color.RByte, color.GByte, color.BByte);
}
public static HumanoidCharacterAppearance EnsureValid(HumanoidCharacterAppearance appearance, string species, Sex sex)
{
var hairStyleId = appearance.HairStyleId;
var facialHairStyleId = appearance.FacialHairStyleId;
var hairColor = ClampColor(appearance.HairColor);
var facialHairColor = ClampColor(appearance.FacialHairColor);
var eyeColor = ClampColor(appearance.EyeColor);
var proto = IoCManager.Resolve<IPrototypeManager>();
var markingManager = IoCManager.Resolve<MarkingManager>();
if (!markingManager.MarkingsByCategory(MarkingCategories.Hair).ContainsKey(hairStyleId))
{
hairStyleId = HairStyles.DefaultHairStyle;
}
if (!markingManager.MarkingsByCategory(MarkingCategories.FacialHair).ContainsKey(facialHairStyleId))
{
facialHairStyleId = HairStyles.DefaultFacialHairStyle;
}
var markingSet = new MarkingSet();
var skinColor = appearance.SkinColor;
if (proto.TryIndex(species, out SpeciesPrototype? speciesProto))
{
markingSet = new MarkingSet(appearance.Markings, speciesProto.MarkingPoints, markingManager, proto);
markingSet.EnsureValid(markingManager);
if (!Humanoid.SkinColor.VerifySkinColor(speciesProto.SkinColoration, skinColor))
{
skinColor = Humanoid.SkinColor.ValidSkinTone(speciesProto.SkinColoration, skinColor);
}
markingSet.EnsureSpecies(species, skinColor, markingManager);
markingSet.EnsureSexes(sex, markingManager);
}
return new HumanoidCharacterAppearance(
hairStyleId,
hairColor,
facialHairStyleId,
facialHairColor,
eyeColor,
skinColor,
markingSet.GetForwardEnumerator().ToList());
}
public bool MemberwiseEquals(ICharacterAppearance maybeOther)
{
return
maybeOther is HumanoidCharacterAppearance other
&& HairStyleId == other.HairStyleId
&& HairColor.Equals(other.HairColor)
&& FacialHairStyleId == other.FacialHairStyleId
&& FacialHairColor.Equals(other.FacialHairColor)
&& EyeColor.Equals(other.EyeColor)
&& SkinColor.Equals(other.SkinColor)
&& Markings.SequenceEqual(other.Markings);
}
public bool Equals(HumanoidCharacterAppearance? other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return HairStyleId == other.HairStyleId
&& HairColor.Equals(other.HairColor)
&& FacialHairStyleId == other.FacialHairStyleId
&& FacialHairColor.Equals(other.FacialHairColor)
&& EyeColor.Equals(other.EyeColor)
&& SkinColor.Equals(other.SkinColor)
&& Markings.SequenceEqual(other.Markings);
}
public override bool Equals(object? obj)
{
return ReferenceEquals(this, obj)
|| obj is HumanoidCharacterAppearance other
&& Equals(other);
}
public override int GetHashCode()
{
return HashCode.Combine(
HairStyleId,
HairColor,
FacialHairStyleId,
FacialHairColor,
EyeColor,
SkinColor,
Markings);
}
public HumanoidCharacterAppearance Clone() => new(this);
}