Adds validation bool for setting humanoid skin color (#15360)
This commit is contained in:
@@ -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)
|
if (!Resolve(uid, ref humanoid) || humanoid.SkinColor == skinColor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
humanoid.SkinColor = skinColor;
|
base.SetSkinColor(uid, skinColor, false, verify, humanoid);
|
||||||
|
|
||||||
if (sync)
|
|
||||||
Dirty(humanoid);
|
|
||||||
|
|
||||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
if (!TryComp(uid, out SpriteComponent? sprite))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ namespace Content.Server.Zombies
|
|||||||
zombiecomp.BeforeZombifiedSkinColor = huApComp.SkinColor;
|
zombiecomp.BeforeZombifiedSkinColor = huApComp.SkinColor;
|
||||||
zombiecomp.BeforeZombifiedCustomBaseLayers = new(huApComp.CustomBaseLayers);
|
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);
|
_sharedHuApp.SetBaseLayerColor(target, HumanoidVisualLayers.Eyes, zombiecomp.EyeColor, humanoid: huApComp);
|
||||||
|
|
||||||
// this might not resync on clone?
|
// this might not resync on clone?
|
||||||
|
|||||||
@@ -144,8 +144,9 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
|||||||
/// <param name="uid">The humanoid mob's UID.</param>
|
/// <param name="uid">The humanoid mob's UID.</param>
|
||||||
/// <param name="skinColor">Skin color to set on the humanoid mob.</param>
|
/// <param name="skinColor">Skin color to set on the humanoid mob.</param>
|
||||||
/// <param name="sync">Whether to synchronize this to the humanoid mob, or not.</param>
|
/// <param name="sync">Whether to synchronize this to the humanoid mob, or not.</param>
|
||||||
|
/// <param name="verify">Whether to verify the skin color can be set on this humanoid or not</param>
|
||||||
/// <param name="humanoid">Humanoid component of the entity</param>
|
/// <param name="humanoid">Humanoid component of the entity</param>
|
||||||
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))
|
if (!Resolve(uid, ref humanoid))
|
||||||
return;
|
return;
|
||||||
@@ -155,7 +156,7 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkinColor.VerifySkinColor(species.SkinColoration, skinColor))
|
if (verify && !SkinColor.VerifySkinColor(species.SkinColoration, skinColor))
|
||||||
{
|
{
|
||||||
skinColor = SkinColor.ValidSkinTone(species.SkinColoration, skinColor);
|
skinColor = SkinColor.ValidSkinTone(species.SkinColoration, skinColor);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user