From: Flipp Syder <76629141+vulppine@users.noreply.github.com>
Date: Sun, 23 Apr 2023 09:16:59 +0000 (-0700)
Subject: Adds validation bool for setting humanoid skin color (#15360)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=c29968372ec8db686611c4a747d8327d035eea23;p=space-station-14.git
Adds validation bool for setting humanoid skin color (#15360)
---
diff --git a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs
index cf37d730e5..141aa34ab7 100644
--- a/Content.Client/Humanoid/HumanoidAppearanceSystem.cs
+++ b/Content.Client/Humanoid/HumanoidAppearanceSystem.cs
@@ -164,7 +164,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
? profile.Appearance.SkinColor.WithAlpha(hairAlpha) : profile.Appearance.HairColor;
var hair = new Marking(profile.Appearance.HairStyleId,
new[] { hairColor });
-
+
var facialHairColor = _markingManager.MustMatchSkin(profile.Species, HumanoidVisualLayers.FacialHair, out var facialHairAlpha, _prototypeManager)
? profile.Appearance.SkinColor.WithAlpha(facialHairAlpha) : profile.Appearance.FacialHairColor;
var facialHair = new Marking(profile.Appearance.FacialHairStyleId,
@@ -178,7 +178,7 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
{
markings.AddBack(MarkingCategories.FacialHair, facialHair);
}
-
+
// Finally adding marking with forced colors
foreach (var (marking, prototype) in markingFColored)
{
@@ -190,10 +190,10 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
);
markings.AddBack(prototype.MarkingCategory, new Marking(marking.MarkingId, markingColors));
}
-
+
markings.EnsureSpecies(profile.Species, profile.Appearance.SkinColor, _markingManager, _prototypeManager);
markings.EnsureDefault(
- profile.Appearance.SkinColor,
+ profile.Appearance.SkinColor,
profile.Appearance.EyeColor,
_markingManager);
@@ -318,13 +318,13 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
}
sprite.LayerSetVisible(layerId, visible);
-
+
if (!visible || setting == null) // this is kinda implied
{
continue;
}
- if (colors != null)
+ if (colors != null)
{
sprite.LayerSetColor(layerId, colors[j]);
}
@@ -335,15 +335,12 @@ public sealed class HumanoidAppearanceSystem : SharedHumanoidAppearanceSystem
}
}
- public override void SetSkinColor(EntityUid uid, Color skinColor, bool sync = true, HumanoidAppearanceComponent? humanoid = null)
+ public override void SetSkinColor(EntityUid uid, Color skinColor, bool sync = true, bool verify = true, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid) || humanoid.SkinColor == skinColor)
return;
- humanoid.SkinColor = skinColor;
-
- if (sync)
- Dirty(humanoid);
+ base.SetSkinColor(uid, skinColor, false, verify, humanoid);
if (!TryComp(uid, out SpriteComponent? sprite))
return;
diff --git a/Content.Server/Zombies/ZombifyOnDeathSystem.cs b/Content.Server/Zombies/ZombifyOnDeathSystem.cs
index ef7203eba6..6ea1a257ff 100644
--- a/Content.Server/Zombies/ZombifyOnDeathSystem.cs
+++ b/Content.Server/Zombies/ZombifyOnDeathSystem.cs
@@ -145,7 +145,7 @@ namespace Content.Server.Zombies
zombiecomp.BeforeZombifiedSkinColor = huApComp.SkinColor;
zombiecomp.BeforeZombifiedCustomBaseLayers = new(huApComp.CustomBaseLayers);
- _sharedHuApp.SetSkinColor(target, zombiecomp.SkinColor, humanoid: huApComp);
+ _sharedHuApp.SetSkinColor(target, zombiecomp.SkinColor, verify: false, humanoid: huApComp);
_sharedHuApp.SetBaseLayerColor(target, HumanoidVisualLayers.Eyes, zombiecomp.EyeColor, humanoid: huApComp);
// this might not resync on clone?
diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
index 0121e5adad..31bcbb56dd 100644
--- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
+++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
@@ -144,8 +144,9 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
/// The humanoid mob's UID.
/// Skin color to set on the humanoid mob.
/// Whether to synchronize this to the humanoid mob, or not.
+ /// Whether to verify the skin color can be set on this humanoid or not
/// Humanoid component of the entity
- public virtual void SetSkinColor(EntityUid uid, Color skinColor, bool sync = true, HumanoidAppearanceComponent? humanoid = null)
+ public virtual void SetSkinColor(EntityUid uid, Color skinColor, bool sync = true, bool verify = true, HumanoidAppearanceComponent? humanoid = null)
{
if (!Resolve(uid, ref humanoid))
return;
@@ -155,7 +156,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
return;
}
- if (!SkinColor.VerifySkinColor(species.SkinColoration, skinColor))
+ if (verify && !SkinColor.VerifySkinColor(species.SkinColoration, skinColor))
{
skinColor = SkinColor.ValidSkinTone(species.SkinColoration, skinColor);
}