chore(release): v1.5.3
Version bumped in manifest.json, the packaging manifest and PluginVersion. Valheim 1.0's new creatures for the Aswid and the Draugh (seal, moose, Elaking, Jotun, Barka, Deep North Goblin and every Dvergr), the Elaking Hair Bundle in the blood refinery, and the Skeleton choosing its look at the barber. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c5ff57530d
commit
b9ac02fe50
15 changed files with 267 additions and 15 deletions
124
JotunnModStub/Skeleton/SkeletonBarber.cs
Normal file
124
JotunnModStub/Skeleton/SkeletonBarber.cs
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The barber's own window, put to work for the Skeleton. Hair and beard are hidden on this
|
||||
/// race, so the two hair arrows would change nothing anyone can see; for a Skeleton they step
|
||||
/// through the bodies this tier has unlocked instead (normal, green, flames), the label
|
||||
/// between them names the one worn, Apply keeps it and Cancel puts the old one back.
|
||||
///
|
||||
/// The look is cosmetic - see SkeletonProgression.ResolveModel - and lives in m_customData,
|
||||
/// which SkeletonRace copies to the ZDO so everyone else sees it too.
|
||||
/// </summary>
|
||||
public static class SkeletonBarber
|
||||
{
|
||||
// What was worn when the chair was sat in, for Cancel.
|
||||
private static string lookOnOpen = "";
|
||||
|
||||
private static bool Active =>
|
||||
Player.m_localPlayer != null && SkeletonRace.IsSkeleton();
|
||||
|
||||
private static void Step(int direction)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
var models = SkeletonProgression.UnlockedModels(state);
|
||||
int at = models.IndexOf(SkeletonVisuals.GetModel(player, state));
|
||||
int next = (at + direction + models.Count) % models.Count;
|
||||
SetLook(player, models[next]);
|
||||
}
|
||||
|
||||
private static void SetLook(Player player, string look)
|
||||
{
|
||||
player.m_customData[SkeletonVisuals.LookDataKey] = look;
|
||||
|
||||
// Rebuild the body now, so the mirror-less barber still shows the result.
|
||||
VisEquipment vis = player.GetComponent<VisEquipment>();
|
||||
if (vis != null) Traverse.Create(vis).Method("UpdateVisuals").GetValue();
|
||||
}
|
||||
|
||||
private static string LabelFor(string model)
|
||||
{
|
||||
return ModText.Get(model == SkeletonProgression.FireModel ? "rov_msg_skeleton_look_flames"
|
||||
: model == SkeletonProgression.PoisonModel ? "rov_msg_skeleton_look_green"
|
||||
: "rov_msg_skeleton_look_normal");
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), nameof(PlayerCustomizaton.ShowBarberGui))]
|
||||
public static class ShowBarberGui_Patch
|
||||
{
|
||||
public static void Postfix()
|
||||
{
|
||||
if (!Active) return;
|
||||
lookOnOpen = SkeletonVisuals.GetModel(Player.m_localPlayer, BossProgressionManager.GetCurrentProgressionState());
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "OnHairLeft")]
|
||||
public static class OnHairLeft_Patch
|
||||
{
|
||||
public static bool Prefix()
|
||||
{
|
||||
if (!Active) return true;
|
||||
Step(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "OnHairRight")]
|
||||
public static class OnHairRight_Patch
|
||||
{
|
||||
public static bool Prefix()
|
||||
{
|
||||
if (!Active) return true;
|
||||
Step(1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// The beard arrows have nothing to do for a Skeleton.
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardLeft")]
|
||||
public static class OnBeardLeft_Patch
|
||||
{
|
||||
public static bool Prefix() => !Active;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardRight")]
|
||||
public static class OnBeardRight_Patch
|
||||
{
|
||||
public static bool Prefix() => !Active;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "OnCancel")]
|
||||
public static class OnCancel_Patch
|
||||
{
|
||||
public static void Prefix()
|
||||
{
|
||||
if (!Active) return;
|
||||
SetLook(Player.m_localPlayer, lookOnOpen);
|
||||
}
|
||||
}
|
||||
|
||||
// The window refreshes its labels every frame, so the name is written after it.
|
||||
[HarmonyPatch(typeof(PlayerCustomizaton), "Update")]
|
||||
public static class Update_Patch
|
||||
{
|
||||
public static void Postfix(PlayerCustomizaton __instance)
|
||||
{
|
||||
if (!Active || !PlayerCustomizaton.IsBarberGuiVisible()) return;
|
||||
|
||||
if (__instance.m_selectedHair != null)
|
||||
{
|
||||
__instance.m_selectedHair.text = LabelFor(
|
||||
SkeletonVisuals.GetModel(Player.m_localPlayer, BossProgressionManager.GetCurrentProgressionState()));
|
||||
}
|
||||
if (__instance.m_beardPanel != null && __instance.m_beardPanel.gameObject.activeSelf)
|
||||
{
|
||||
__instance.m_beardPanel.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -263,7 +263,10 @@ namespace RacesOfValheim
|
|||
|
||||
int state = SkeletonVisuals.GetProgressionState(p);
|
||||
SkeletonProgression.SkeletonRules rules = SkeletonProgression.GetRules(state);
|
||||
string targetBodyName = $"SkeletonBody_{rules.ModelPrefab}";
|
||||
// The look chosen at the barber, when it is still unlocked; the tier's own
|
||||
// body otherwise. Cosmetic: rules keeps driving every ability.
|
||||
string modelPrefab = SkeletonVisuals.GetModel(p, state);
|
||||
string targetBodyName = $"SkeletonBody_{modelPrefab}";
|
||||
|
||||
// Check if we already created the Skeleton body for this VisEquipment
|
||||
Transform parentTransform = __instance.m_bodyModel.transform.parent;
|
||||
|
|
@ -282,21 +285,21 @@ namespace RacesOfValheim
|
|||
|
||||
if (skeletonBodyTransform == null)
|
||||
{
|
||||
GameObject skelPrefab = PrefabManager.Cache.GetPrefab<GameObject>(rules.ModelPrefab);
|
||||
GameObject skelPrefab = PrefabManager.Cache.GetPrefab<GameObject>(modelPrefab);
|
||||
|
||||
// The cache answers by name alone, and every magic mod named in the
|
||||
// purple-smoke report carries an object of its own called "Skeleton" -
|
||||
// which is this race's own tier-0 model name. So far the vanilla
|
||||
// creature has always won; the log is here to say so, or to say which
|
||||
// mod's object took its place. See SkeletonVisuals.EnsureFireAura.
|
||||
SkeletonVisuals.LogResolvedPrefabOnce("model " + rules.ModelPrefab, skelPrefab);
|
||||
SkeletonVisuals.LogResolvedPrefabOnce("model " + modelPrefab, skelPrefab);
|
||||
|
||||
if (skelPrefab == null)
|
||||
{
|
||||
// The human body was switched off two lines up, so an unresolved
|
||||
// model leaves an invisible player rather than an obvious error.
|
||||
// Say so once per tier instead of failing silently.
|
||||
WarnMissingModelOnce(rules.ModelPrefab);
|
||||
WarnMissingModelOnce(modelPrefab);
|
||||
}
|
||||
if (skelPrefab != null)
|
||||
{
|
||||
|
|
@ -312,7 +315,7 @@ namespace RacesOfValheim
|
|||
|
||||
// Map bones by name
|
||||
Transform[] playerBones = __instance.m_bodyModel.bones;
|
||||
LogBoneMapping(rules.ModelPrefab, newSmr, playerBones);
|
||||
LogBoneMapping(modelPrefab, newSmr, playerBones);
|
||||
|
||||
Transform[] newBones = new Transform[newSmr.bones.Length];
|
||||
for (int i = 0; i < newSmr.bones.Length; i++)
|
||||
|
|
@ -360,7 +363,7 @@ namespace RacesOfValheim
|
|||
// that each one arrives its own colour. Outside the build block above on
|
||||
// purpose: they hang off the player's rig bones rather than off the body
|
||||
// container, so they outlive it and have to be checked every refresh.
|
||||
SkeletonEyeGlow.Apply(__instance, rules.ModelPrefab);
|
||||
SkeletonEyeGlow.Apply(__instance, modelPrefab);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -67,6 +67,28 @@ namespace RacesOfValheim
|
|||
///
|
||||
/// The blocks are cumulative: each one only states what its boss adds or replaces.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// The bodies this tier has earned, plainest first. These are the same thresholds
|
||||
/// GetRules switches the model at, so a look can never be worn before its boss is down.
|
||||
/// </summary>
|
||||
public static System.Collections.Generic.List<string> UnlockedModels(int state)
|
||||
{
|
||||
var models = new System.Collections.Generic.List<string> { BaseModel };
|
||||
if (state >= 2) models.Add(PoisonModel); // Eikthyr
|
||||
if (state >= 5) models.Add(FireModel); // Moder
|
||||
return models;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The body to build: the one chosen at the barber when it is still unlocked, otherwise
|
||||
/// the tier's own. Cosmetic only - every rule in GetRules keeps following the tier.
|
||||
/// </summary>
|
||||
public static string ResolveModel(int state, string look)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(look) && UnlockedModels(state).Contains(look)) return look;
|
||||
return GetRules(state).ModelPrefab;
|
||||
}
|
||||
|
||||
public static SkeletonRules GetRules(int state)
|
||||
{
|
||||
SkeletonRules rules = new SkeletonRules
|
||||
|
|
|
|||
|
|
@ -374,6 +374,14 @@ namespace RacesOfValheim
|
|||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
nview.GetZDO().Set("RacesOfValheim_SkeletonState", state);
|
||||
|
||||
// The saved look goes on the ZDO so everyone else sees the same body.
|
||||
Player.m_localPlayer.m_customData.TryGetValue(SkeletonVisuals.LookDataKey, out string savedLook);
|
||||
savedLook = savedLook ?? "";
|
||||
if (nview.GetZDO().GetString(SkeletonVisuals.LookZdoKey, "") != savedLook)
|
||||
{
|
||||
nview.GetZDO().Set(SkeletonVisuals.LookZdoKey, savedLook);
|
||||
}
|
||||
}
|
||||
|
||||
// Manage Fake Foods
|
||||
|
|
@ -442,7 +450,7 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
// Flames on the skull, worn with the fire-tier model and nothing else.
|
||||
headFlame.Apply(Player.m_localPlayer, SkeletonConfig.HeadFireVFXEnabled.Value && rules.ModelPrefab == SkeletonProgression.FireModel);
|
||||
headFlame.Apply(Player.m_localPlayer, SkeletonConfig.HeadFireVFXEnabled.Value && SkeletonVisuals.GetModel(Player.m_localPlayer, state) == SkeletonProgression.FireModel);
|
||||
|
||||
if (rules.FireAura)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,6 +97,37 @@ namespace RacesOfValheim
|
|||
return BossProgressionManager.GetCurrentProgressionState();
|
||||
}
|
||||
|
||||
public const string LookZdoKey = "RacesOfValheim_SkeletonLook";
|
||||
public const string LookDataKey = "SkeletonLook";
|
||||
|
||||
/// <summary>
|
||||
/// The body this player chose at the barber, "" if they never did. Read the same way as
|
||||
/// the race: the ZDO for anyone on the network, m_customData for the menu preview.
|
||||
/// </summary>
|
||||
public static string GetLook(Player player)
|
||||
{
|
||||
if (player == null) return "";
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
return nview.GetZDO().GetString(LookZdoKey, "");
|
||||
}
|
||||
|
||||
if (player.m_customData != null && player.m_customData.TryGetValue(LookDataKey, out string look))
|
||||
{
|
||||
return look;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>The model prefab to wear for this player at this tier, look applied.</summary>
|
||||
public static string GetModel(Player player, int state)
|
||||
{
|
||||
return SkeletonProgression.ResolveModel(state, GetLook(player));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fire sources in preference order. BUILDING PIECES ONLY, and that is the bug fix.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue