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:
parent
79a54fb533
commit
8df7681cea
4 changed files with 60 additions and 47 deletions
|
|
@ -78,40 +78,6 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// ─── Skin ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Tints the local player's skin, saving the original first so ResetRace can put it back.
|
||||
/// Same save-then-tint dance the Furling, Trol and Draugh selections do.
|
||||
/// </summary>
|
||||
public static void ApplySkinColor(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
VisEquipment visEq = player.GetComponent<VisEquipment>();
|
||||
if (visEq == null) return;
|
||||
|
||||
if (!player.m_customData.ContainsKey("OriginalSkinColor_X"))
|
||||
{
|
||||
Vector3 current = Traverse.Create(visEq).Field("m_skinColor").GetValue<Vector3>();
|
||||
player.m_customData["OriginalSkinColor_X"] = current.x.ToString();
|
||||
player.m_customData["OriginalSkinColor_Y"] = current.y.ToString();
|
||||
player.m_customData["OriginalSkinColor_Z"] = current.z.ToString();
|
||||
}
|
||||
|
||||
Traverse.Create(visEq).Method("SetSkinColor", DvergurConfig.SkinColor).GetValue();
|
||||
RefreshColors(visEq);
|
||||
}
|
||||
|
||||
public static void RefreshColors(VisEquipment visEq)
|
||||
{
|
||||
if (visEq == null) return;
|
||||
visEq.GetType().GetMethod("UpdateColors",
|
||||
System.Reflection.BindingFlags.Instance |
|
||||
System.Reflection.BindingFlags.NonPublic |
|
||||
System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
||||
}
|
||||
|
||||
// ─── Hood ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue