From 15eb37b1ecc9003385f63d821c7f04595f38b430 Mon Sep 17 00:00:00 2001 From: FoxxoTrystan Date: Wed, 9 Oct 2024 23:15:32 +0200 Subject: [PATCH] EyeColorFix --- Content.Server/Shadowkin/ShadowkinSystem.cs | 13 +++++++++++++ Content.Shared/Humanoid/EyeColor.cs | 4 ++++ .../Humanoid/SharedHumanoidAppearanceSystem.cs | 4 +++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/Humanoid/EyeColor.cs diff --git a/Content.Server/Shadowkin/ShadowkinSystem.cs b/Content.Server/Shadowkin/ShadowkinSystem.cs index ee7d9e6055c..d0a0dd4b2ca 100644 --- a/Content.Server/Shadowkin/ShadowkinSystem.cs +++ b/Content.Server/Shadowkin/ShadowkinSystem.cs @@ -35,6 +35,7 @@ public override void Initialize() SubscribeLocalEvent(OnAttemptPowerUse); SubscribeLocalEvent(OnManaUpdate); SubscribeLocalEvent(OnRejuvenate); + SubscribeLocalEvent(OnEyeColorChange); } private void OnInit(EntityUid uid, ShadowkinComponent component, ComponentStartup args) @@ -47,6 +48,18 @@ private void OnInit(EntityUid uid, ShadowkinComponent component, ComponentStartu UpdateShadowkinAlert(uid, component); } + private void OnEyeColorChange(EntityUid uid, ShadowkinComponent component, EyeColorInitEvent args) + { + if (!TryComp(uid, out var humanoid) + || !component.BlackeyeSpawn + || humanoid.EyeColor == component.OldEyeColor) + return; + + component.OldEyeColor = humanoid.EyeColor; + humanoid.EyeColor = component.BlackEyeColor; + Dirty(humanoid); + } + private void OnExamined(EntityUid uid, ShadowkinComponent component, ExaminedEvent args) { if (!args.IsInDetailsRange diff --git a/Content.Shared/Humanoid/EyeColor.cs b/Content.Shared/Humanoid/EyeColor.cs new file mode 100644 index 00000000000..a39e090a86c --- /dev/null +++ b/Content.Shared/Humanoid/EyeColor.cs @@ -0,0 +1,4 @@ +namespace Content.Shared.Humanoid; + +[ByRefEvent] +public record struct EyeColorInitEvent(); \ No newline at end of file diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index 87b0508b980..b78809ae4ed 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -345,9 +345,11 @@ public virtual void LoadProfile(EntityUid uid, HumanoidCharacterProfile? profile return; } - humanoid.EyeColor = profile.Appearance.EyeColor; SetSpecies(uid, profile.Species, false, humanoid); SetSex(uid, profile.Sex, false, humanoid); + humanoid.EyeColor = profile.Appearance.EyeColor; + var ev = new EyeColorInitEvent(); + RaiseLocalEvent(uid, ref ev); SetSkinColor(uid, profile.Appearance.SkinColor, false);