diff --git a/JotunnModStub/Alfar/AlfarPatches.cs b/JotunnModStub/Alfar/AlfarPatches.cs index 5d5e5ea..73864de 100644 --- a/JotunnModStub/Alfar/AlfarPatches.cs +++ b/JotunnModStub/Alfar/AlfarPatches.cs @@ -38,6 +38,37 @@ namespace RacesOfValheim } } + /// + /// Hair and beard never attach to an Alfr. Every equipment change makes the game write the + /// profile's hair back (Humanoid.SetupVisEquipment), and ApplyHairless only clears it on its + /// 0.5s pass, so players saw the hair flash in for a moment. Zeroing the hash here, where + /// VisEquipment spawns the model, means it never appears. Covers remote players too, since + /// their visuals go through the same call. + /// + [HarmonyPatch(typeof(VisEquipment), "SetHairEquipped")] + public static class Alfar_SetHairEquipped_Patch + { + public static void Prefix(VisEquipment __instance, ref int hash) + { + if (hash != 0 && IsAlfarVis(__instance)) hash = 0; + } + } + + [HarmonyPatch(typeof(VisEquipment), "SetBeardEquipped")] + public static class Alfar_SetBeardEquipped_Patch + { + public static void Prefix(VisEquipment __instance, ref int hash) + { + if (hash != 0 && IsAlfarVis(__instance)) hash = 0; + } + } + + private static bool IsAlfarVis(VisEquipment vis) + { + Player player = vis.GetComponent(); + return player != null && AlfarVisuals.IsAlfarPlayer(player); + } + /// /// The character preview on the main menu is a Player too, with the saved race in its custom data /// and no ZNetView. Its Update may never run, so a small driver on it keeps the look: skin, hair,