RacesOfValheim/JotunnModStub/Aswid/AswidClaws.cs
2026-08-11 19:29:58 +02:00

69 lines
2.9 KiB
C#

using UnityEngine;
namespace RacesOfValheim
{
/// <summary>
/// The Claws of the Beast: the Bjorn claw, burned down to almost black.
///
/// Everything about how they behave - issued once, never dropped, back in hand the moment the
/// hands are free, tier damage as slash - lives in RaceClawSet. This file is only the Aswid's
/// half of the answer: which model, what colour, and when the race is wearing another body.
///
/// The tint is config rather than a constant because "almost black" is a look, not a number,
/// and it needs one pass in front of a mirror. It is applied to the item's own copies of the
/// model's materials, so the vanilla weapon is untouched for everyone else.
/// </summary>
public class AswidClaws : RaceClawSet
{
public static readonly AswidClaws Instance = new AswidClaws();
public override string RaceId => "Aswid";
public override string ItemName => "AswidBeastClaws";
public override string DisplayName => "Claws of the Beast";
public override string Description => "Grown in the dark, and darker for it. They do not come off.";
// The Bjorn claw first, by name, because that is the one this race is meant to wear. The
// rest are the near-identical ids the manifest also carries - see SvermConfig's own
// fallback list for why a single name is not trusted here.
public override string[] ModelPrefabs => new[]
{
"FistBjornClaw",
"FistBjornUndeadClaw",
"FistBjornClawUndead",
"FistUnbjornClaw",
};
/// <summary>Published by AswidRace.UpdateAswidState, so a remote Aswid claws at its own tier.</summary>
public override string StateZdoKey => "RacesOfValheim_AswidState";
public override Color? Tint => new Color(
AswidConfig.ClawTintRed.Value,
AswidConfig.ClawTintGreen.Value,
AswidConfig.ClawTintBlue.Value,
1f);
/// <summary>
/// A bat and a bank of mist have no hands. IsTransformed is the local player's own flag;
/// the two ZDO booleans are how AswidPatches already publishes the same thing for everyone
/// else, which is what makes this answer correctly for a remote attacker.
/// </summary>
public override bool IsTransformed(Player player)
{
if (player == null) return false;
if (player == Player.m_localPlayer && AswidRace.Instance != null && AswidRace.Instance.IsTransformed)
{
return true;
}
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid())
{
return nview.GetZDO().GetBool("Aswid_IsBatForm", false) ||
nview.GetZDO().GetBool("Aswid_IsMistForm", false);
}
return false;
}
}
}