From 0aa0abb949ef86190a3ae8290043246d6cabb822 Mon Sep 17 00:00:00 2001 From: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com> Date: Sun, 19 May 2024 00:46:19 +1000 Subject: [PATCH] New tiefling hue (#155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Добавлен отдельный тип цвета кожи для тифлингов * Немного чистки * Автоматом поправил, будет мешать при мердже --- .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 30 +++++++++++++++ .../Humanoid/HumanoidCharacterAppearance.cs | 6 +++ Content.Shared/Humanoid/SkinColor.cs | 10 +++++ .../_CP14/Humanoid/CP14SkinColor.cs | 38 +++++++++++++++++++ .../Prototypes/_CP14/Species/tiefling.yml | 2 +- 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/_CP14/Humanoid/CP14SkinColor.cs diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs index a0e32a3a49..dee6cf8d09 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs @@ -8,6 +8,7 @@ using Content.Client.Lobby.UI.Roles; using Content.Client.Message; using Content.Client.Players.PlayTimeTracking; using Content.Client.UserInterface.Systems.Guidebook; +using Content.Shared._CP14.Humanoid; using Content.Shared.CCVar; using Content.Shared.Clothing; using Content.Shared.GameTicking; @@ -1015,6 +1016,22 @@ namespace Content.Client.Lobby.UI Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color)); break; } + // CP14 - Custom HumanoidSkinColor - Start + case HumanoidSkinColor.TieflingHues: + { + if (!RgbSkinColorContainer.Visible) + { + Skin.Visible = false; + RgbSkinColorContainer.Visible = true; + } + + var color = CP14SkinColor.MakeTieflingHueValid(_rgbSkinColorSelector.Color); + + Markings.CurrentSkinColor = color; + Profile = Profile.WithCharacterAppearance(Profile.Appearance.WithSkinColor(color)); + break; + } + // CP14 - Custom HumanoidSkinColor - End } SetDirty(); @@ -1231,6 +1248,19 @@ namespace Content.Client.Lobby.UI break; } + // CP14 - Custom HumanoidSkinColor - Start + case HumanoidSkinColor.TieflingHues: + { + if (!RgbSkinColorContainer.Visible) + { + Skin.Visible = false; + RgbSkinColorContainer.Visible = true; + } + + _rgbSkinColorSelector.Color = CP14SkinColor.MakeTieflingHueValid(Profile.Appearance.SkinColor); + break; + } + // CP14 - Custom HumanoidSkinColor - End } } diff --git a/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs b/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs index 05bebea075..5d017b2e68 100644 --- a/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs +++ b/Content.Shared/Humanoid/HumanoidCharacterAppearance.cs @@ -1,4 +1,5 @@ using System.Linq; +using Content.Shared._CP14.Humanoid; using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Prototypes; using Robust.Shared.Prototypes; @@ -164,6 +165,11 @@ public sealed partial class HumanoidCharacterAppearance : ICharacterAppearance, case HumanoidSkinColor.VoxFeathers: newSkinColor = Humanoid.SkinColor.ProportionalVoxColor(newSkinColor); break; + // CP14 - Custom HumanoidSkinColor - Start + case HumanoidSkinColor.TieflingHues: + newSkinColor = CP14SkinColor.TieflingHues(newSkinColor); + break; + // CP14 - Custom HumanoidSkinColor - End } return new HumanoidCharacterAppearance(newHairStyle, newHairColor, newFacialHairStyle, newHairColor, newEyeColor, newSkinColor, new ()); diff --git a/Content.Shared/Humanoid/SkinColor.cs b/Content.Shared/Humanoid/SkinColor.cs index 2dc95fcf07..07119880bb 100644 --- a/Content.Shared/Humanoid/SkinColor.cs +++ b/Content.Shared/Humanoid/SkinColor.cs @@ -1,4 +1,5 @@ using System.Security.Cryptography; +using Content.Shared._CP14.Humanoid; using Microsoft.VisualBasic.CompilerServices; namespace Content.Shared.Humanoid; @@ -234,6 +235,9 @@ public static class SkinColor HumanoidSkinColor.TintedHues => VerifyTintedHues(color), HumanoidSkinColor.Hues => VerifyHues(color), HumanoidSkinColor.VoxFeathers => VerifyVoxFeathers(color), + // CP14 - Custom HumanoidSkinColor - Start + HumanoidSkinColor.TieflingHues => CP14SkinColor.VerifyTieflingHues(color), + // CP14 - Custom HumanoidSkinColor - End _ => false, }; } @@ -246,6 +250,9 @@ public static class SkinColor HumanoidSkinColor.TintedHues => ValidTintedHuesSkinTone(color), HumanoidSkinColor.Hues => MakeHueValid(color), HumanoidSkinColor.VoxFeathers => ClosestVoxColor(color), + // CP14 - Custom HumanoidSkinColor - Start + HumanoidSkinColor.TieflingHues => CP14SkinColor.MakeTieflingHueValid(color), + // CP14 - Custom HumanoidSkinColor - End _ => color }; } @@ -257,4 +264,7 @@ public enum HumanoidSkinColor : byte Hues, VoxFeathers, // Vox feathers are limited to a specific color range TintedHues, //This gives a color tint to a humanoid's skin (10% saturation with full hue range). + // CP14 - Custom HumanoidSkinColor - Start + TieflingHues, + // CP14 - Custom HumanoidSkinColor - End } diff --git a/Content.Shared/_CP14/Humanoid/CP14SkinColor.cs b/Content.Shared/_CP14/Humanoid/CP14SkinColor.cs new file mode 100644 index 0000000000..5f92fca0ed --- /dev/null +++ b/Content.Shared/_CP14/Humanoid/CP14SkinColor.cs @@ -0,0 +1,38 @@ +namespace Content.Shared._CP14.Humanoid; + +public static class CP14SkinColor +{ + public const float MinTieflingHuesLightness = 10f / 100f; + public const float MaxTieflingHuesLightness = 35f / 100f; + + public static Color TieflingHues(Color color) + { + return color; + } + + public static Color MakeTieflingHueValid(Color color) + { + color.G = Math.Min(color.G, color.B); + + var hsl = Color.ToHsl(color); + hsl.Z = Math.Clamp(hsl.Z, MinTieflingHuesLightness, MaxTieflingHuesLightness); + + return Color.FromHsl(hsl); + } + + public static bool VerifyTieflingHues(Color color) + { + var hsl = Color.ToHsl(color); + var lightness = hsl.Z; + + // Allows you to use shades of green, but not make green tieflings + if (color.G > color.B) + return false; + + // No black or white holes instead of tieflings + if (lightness is < MinTieflingHuesLightness or > MaxTieflingHuesLightness) + return false; + + return true; + } +} diff --git a/Resources/Prototypes/_CP14/Species/tiefling.yml b/Resources/Prototypes/_CP14/Species/tiefling.yml index 550799e1eb..c677574f8e 100644 --- a/Resources/Prototypes/_CP14/Species/tiefling.yml +++ b/Resources/Prototypes/_CP14/Species/tiefling.yml @@ -6,7 +6,7 @@ sprites: CP14MobTieflingSprites markingLimits: CP14MobTieflingMarkingLimits dollPrototype: CP14MobTieflingDummy - skinColoration: Hues + skinColoration: TieflingHues maleFirstNames: CP14_Names_Tiefling_Male_First femaleFirstNames: CP14_Names_Tiefling_Female_First lastNames: CP14_Names_Tiefling_Last