Marking default coloring (#13039)

* Marking coloring WIP

* EnsureDefault now supports coloring!

* Now markings have coloring when they get added

* Many things

* yml files

* cleanup

* Some requested changes

* Nullable type and WIP caching

* Time to resolve that thing with deprecated hair fields

* Latest reviews + im still trying to use these hair markings

* FirstOrDefault thing and Tattoo docs

* IDK

* It's now works a bit more properly in preferences GUI

* THEY SYNCING! However preferences GUI still broken and doesn't work properly

* Markings now updating when changing in GUI. However they still don't work properly with bald humanoids

* Forgor...

* Default hair-colored markings will not color to hair if there is no hair

* Fixed default colors for customizable markings

* Fixed bug in prefs GUI that set current hair to null

* Now markings that must match skin color because of limb (e.x. Slimes) - will match skin color

* final tweaks: if hair uses skin color then markings will use skin color as hair color (slimes)

* fix

* fixed dirty. no more funni invis bug

* Mirrors and client profile loading

* default colors soon TM

* review + better coloring

* Hardcode is gone

* diona markings

* oh my god

* fixed CategoryColoring

* cool fallback, clean up and some other tweaks

* code style

* more style

* a
This commit is contained in:
csqrb
2023-03-05 08:59:07 +06:00
committed by GitHub
parent 0ad9af7ae2
commit 8b3d7728d7
26 changed files with 863 additions and 83 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using Content.Shared.Humanoid.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Humanoid.Markings;
@@ -104,6 +105,22 @@ public sealed class MarkingSet
}
}
/// <summary>
/// Construct a MarkingSet only with a points dictionary.
/// </summary>
/// <param name="pointsPrototype">The ID of the points dictionary prototype.</param>
public MarkingSet(string pointsPrototype, MarkingManager? markingManager = null, IPrototypeManager? prototypeManager = null)
{
IoCManager.Resolve(ref markingManager, ref prototypeManager);
if (!prototypeManager.TryIndex(pointsPrototype, out MarkingPointsPrototype? points))
{
return;
}
Points = MarkingPoints.CloneMarkingPointDictionary(points.Points);
}
/// <summary>
/// Construct a MarkingSet by deep cloning another set.
/// </summary>
@@ -122,12 +139,13 @@ public sealed class MarkingSet
}
/// <summary>
/// Filters markings based on species restrictions in the marking's prototype from this marking set.
/// Filters and colors markings based on species and it's restrictions in the marking's prototype from this marking set.
/// </summary>
/// <param name="species">The species to filter.</param>
/// <param name="skinColor">The skin color for recoloring (i.e. slimes). Use null if you want only filter markings</param>
/// <param name="markingManager">Marking manager.</param>
/// <param name="prototypeManager">Prototype manager.</param>
public void FilterSpecies(string species, MarkingManager? markingManager = null, IPrototypeManager? prototypeManager = null)
public void EnsureSpecies(string species, Color? skinColor, MarkingManager? markingManager = null, IPrototypeManager? prototypeManager = null)
{
IoCManager.Resolve(ref markingManager);
IoCManager.Resolve(ref prototypeManager);
@@ -163,6 +181,22 @@ public sealed class MarkingSet
{
Remove(remove.category, remove.id);
}
// Re-color left markings them into skin color if needed (i.e. for slimes)
if (skinColor != null)
{
foreach (var (category, list) in Markings)
{
foreach (var marking in list)
{
if (markingManager.TryGetMarking(marking, out var prototype) &&
markingManager.MustMatchSkin(species, prototype.BodyPart, prototypeManager))
{
marking.SetColor(skinColor.Value);
}
}
}
}
}
/// <summary>
@@ -200,9 +234,11 @@ public sealed class MarkingSet
/// <summary>
/// Ensures that the default markings as defined by the marking point set in this marking set are applied.
/// </summary>
/// <param name="skinColor">Color to apply.</param>
/// <param name="skinColor">Skin color for marking coloring.</param>
/// <param name="eyeColor">Eye color for marking coloring.</param>
/// <param name="hairColor">Hair color for marking coloring.</param>
/// <param name="markingManager">Marking manager.</param>
public void EnsureDefault(Color? skinColor = null, MarkingManager? markingManager = null)
public void EnsureDefault(Color? skinColor = null, Color? eyeColor = null, MarkingManager? markingManager = null)
{
IoCManager.Resolve(ref markingManager);
@@ -218,22 +254,13 @@ public sealed class MarkingSet
{
if (markingManager.Markings.TryGetValue(points.DefaultMarkings[index], out var prototype))
{
Marking marking;
if (skinColor == null)
{
marking = new Marking(points.DefaultMarkings[index], prototype.Sprites.Count);
}
else
{
var colors = new List<Color>();
for (var i = 0; i < prototype.Sprites.Count; i++)
{
colors.Add(skinColor.Value);
}
marking = new Marking(points.DefaultMarkings[index], colors);
}
var colors = MarkingColoring.GetMarkingLayerColors(
prototype,
skinColor,
eyeColor,
this
);
var marking = new Marking(points.DefaultMarkings[index], colors);
AddBack(category, marking);
}