1.0 compatibility
This commit is contained in:
parent
5104f86ede
commit
6193b3ee2d
33 changed files with 712 additions and 49 deletions
|
|
@ -467,6 +467,10 @@ namespace RacesOfValheim
|
|||
"[<color=yellow><b>$KEY_Use</b></color>] Feed it a stack";
|
||||
}
|
||||
|
||||
// New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
|
||||
// serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
|
||||
public float GetHoverOffset() => 0f;
|
||||
|
||||
public string GetHoverName() => SvermHiveStage.NameOf(SvermHiveStage.Of(transform));
|
||||
|
||||
private ZNetView nview;
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ namespace RacesOfValheim
|
|||
|
||||
public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false;
|
||||
|
||||
// New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
|
||||
// serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
|
||||
public float GetHoverOffset() => 0f;
|
||||
|
||||
public string GetHoverName() => Title;
|
||||
|
||||
public string GetHoverText()
|
||||
|
|
@ -444,6 +448,10 @@ namespace RacesOfValheim
|
|||
|
||||
public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false;
|
||||
|
||||
// New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
|
||||
// serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
|
||||
public float GetHoverOffset() => 0f;
|
||||
|
||||
public string GetHoverName() => SvermHiveMarketPiece.DisplayName;
|
||||
|
||||
public string GetHoverText()
|
||||
|
|
|
|||
|
|
@ -682,9 +682,10 @@ namespace RacesOfValheim
|
|||
|
||||
if (player.GetComponent<CarapaceMark>() == null) player.gameObject.AddComponent<CarapaceMark>();
|
||||
|
||||
visEq.SetChestItem(SvermConfig.CarapaceChestVisual);
|
||||
visEq.SetLegItem(SvermConfig.CarapaceLegsVisual);
|
||||
visEq.SetHelmetItem(SvermConfig.CarapaceHelmetVisual);
|
||||
// Since Valheim 1.0 these three take an item hash rather than a prefab name.
|
||||
visEq.SetChestItem(VisualHash(SvermConfig.CarapaceChestVisual));
|
||||
visEq.SetLegItem(VisualHash(SvermConfig.CarapaceLegsVisual));
|
||||
visEq.SetHelmetItem(VisualHash(SvermConfig.CarapaceHelmetVisual));
|
||||
|
||||
int state = GetRenderState(player);
|
||||
|
||||
|
|
@ -697,7 +698,7 @@ namespace RacesOfValheim
|
|||
/// Puts the three slots back to whatever the player actually has equipped.
|
||||
///
|
||||
/// The same three lines vanilla's own Humanoid.SetupVisEquipment writes - the item's drop
|
||||
/// prefab name, or "" for an empty slot - rather than calling that method, because it also
|
||||
/// prefab name hashed, or 0 when empty - rather than calling that method, because it also
|
||||
/// rewrites the hands, the shoulders and the utility slot, and the Sverm never touched
|
||||
/// those. Restoring only what was overridden cannot disturb another race's visuals or a
|
||||
/// weapon that some other patch is mid-way through swapping.
|
||||
|
|
@ -707,17 +708,25 @@ namespace RacesOfValheim
|
|||
/// </summary>
|
||||
private static void RestoreEquipmentVisuals(Player player, VisEquipment visEq)
|
||||
{
|
||||
visEq.SetChestItem(EquippedVisualName(player, "m_chestItem"));
|
||||
visEq.SetLegItem(EquippedVisualName(player, "m_legItem"));
|
||||
visEq.SetHelmetItem(EquippedVisualName(player, "m_helmetItem"));
|
||||
visEq.SetChestItem(EquippedVisualHash(player, "m_chestItem"));
|
||||
visEq.SetLegItem(EquippedVisualHash(player, "m_legItem"));
|
||||
visEq.SetHelmetItem(EquippedVisualHash(player, "m_helmetItem"));
|
||||
}
|
||||
|
||||
/// <summary>The prefab name VisEquipment wants for an equipped slot, or "" when it is empty.</summary>
|
||||
private static string EquippedVisualName(Player player, string field)
|
||||
/// <summary>
|
||||
/// What VisEquipment has wanted since Valheim 1.0: an item hash instead of a prefab name.
|
||||
/// 0 is the empty slot - the same value vanilla Humanoid.SetupVisEquipment passes for a
|
||||
/// slot holding nothing.
|
||||
/// </summary>
|
||||
private static int VisualHash(string prefabName) =>
|
||||
string.IsNullOrEmpty(prefabName) ? 0 : prefabName.GetStableHashCode();
|
||||
|
||||
/// <summary>The item hash VisEquipment wants for an equipped slot, or 0 when it is empty.</summary>
|
||||
private static int EquippedVisualHash(Player player, string field)
|
||||
{
|
||||
ItemDrop.ItemData item = Traverse.Create((Humanoid)player).Field<ItemDrop.ItemData>(field).Value;
|
||||
if (item == null || item.m_dropPrefab == null) return "";
|
||||
return item.m_dropPrefab.name;
|
||||
if (item == null || item.m_dropPrefab == null) return 0;
|
||||
return VisualHash(item.m_dropPrefab.name);
|
||||
}
|
||||
|
||||
private static void TintInstances(object value, int state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue