fix(dvergur): tint the skin from UpdateColors, and raise the height

The tint was applied the way the race-selection menu appears to do it, with
VisEquipment.SetSkinColor followed by UpdateColors, and had no visible effect.
That pair is not what colours a player: UpdateColors rebuilds the body material
from Valheim own state each refresh, so a tint only survives if it is written
after it runs. Every race here that visibly changes colour already has a
postfix on UpdateColors setting _SkinColor on the material, and the SetSkinColor
calls in the menu are decorative on their own. The Dvergur now follows the Trol.

Reading the race from the ZDO with a m_customData fallback and no local-player
check covers the main-menu preview and the first spawn frame, where
Player.m_localPlayer is still null. Nothing needs saving or restoring either,
since the tint stops being applied the moment the race changes.

Beard and hair go pale to match; the hood hides most of the hair but the beard
shows.

Height goes from 0.70 to 0.78. The spec asked for at least -30% but that read as
too small beside a human on screen.
This commit is contained in:
kanym 2026-08-02 23:08:12 +02:00
commit 8df7681cea
4 changed files with 60 additions and 47 deletions

View file

@ -593,9 +593,8 @@ namespace RacesOfValheim
Player.m_localPlayer.GetSEMan().AddStatusEffect(DvergurConfig.StatsSE.GetStableHashCode(), true);
// Saves the original skin first, so ResetRace can hand it back.
DvergurVisuals.ApplySkinColor(Player.m_localPlayer);
// No SetSkinColor here: the tint is written onto the material by the UpdateColors
// postfix in DvergurPatches, which keys off the race and so needs nothing saved.
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
if (visEq != null)
{
@ -692,12 +691,8 @@ namespace RacesOfValheim
if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
}
// Re-tinted rather than merely refreshed: the skin colour is the one piece of the
// Dvergur that is not rebuilt from the race id on its own.
if (__instance.m_customData.ContainsKey("Race") && __instance.m_customData["Race"] == DvergurConfig.RaceId)
{
DvergurVisuals.ApplySkinColor(__instance);
}
// The Dvergur needs no entry here: its tint is applied by the UpdateColors postfix
// every time Valheim refreshes the body, rather than being stored on the player.
// Check for Race Selection
if (!__instance.m_customData.ContainsKey("Race"))