warvulture
This commit is contained in:
parent
d79f78e9f0
commit
8580d65a56
4 changed files with 90 additions and 7 deletions
|
|
@ -89,6 +89,36 @@ namespace RacesOfValheim
|
|||
"cloned from vanilla's mount stamina bar."));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The race of a player, read m_customData first and the ZDO second.
|
||||
///
|
||||
/// That order is the one the summon has always used, and it is kept rather than swapped for
|
||||
/// the ZDO-first order the visuals use, for a reason: this only ever asks about the LOCAL
|
||||
/// player, whose m_customData is authoritative and is written before the ZDO on a race
|
||||
/// change. The ZDO is the fallback for the one frame after a load where m_customData has not
|
||||
/// been filled in yet - without it the crafting list would flicker the recipe away.
|
||||
/// </summary>
|
||||
public static string RaceOf(Player player)
|
||||
{
|
||||
if (player == null) return null;
|
||||
|
||||
if (player.m_customData != null &&
|
||||
player.m_customData.TryGetValue("Race", out string custom) &&
|
||||
!string.IsNullOrEmpty(custom))
|
||||
{
|
||||
return custom;
|
||||
}
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
string race = nview.GetZDO().GetString("RacesOfValheim_Race", "");
|
||||
if (!string.IsNullOrEmpty(race)) return race;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether a race id may call the bird. An empty list means everyone, which is the honest
|
||||
/// reading of "no restriction" and is also what makes this testable on any character.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue