aswig and multiplayer fixes

This commit is contained in:
Ferdinando 2026-08-02 17:54:39 +02:00
commit 1bdf77e8d6
6 changed files with 102 additions and 49 deletions

View file

@ -76,6 +76,11 @@ namespace RacesOfValheim
formInstance.name = wanted;
formInstance.transform.localPosition = formName == "Hatchling" ? new Vector3(0f, -1.0f, 0f) : Vector3.zero;
formInstance.transform.localRotation = Quaternion.identity;
if (formInstance.GetComponent<RemoteSkadiAnimator>() == null)
{
formInstance.AddComponent<RemoteSkadiAnimator>();
}
}
}
@ -83,6 +88,34 @@ namespace RacesOfValheim
}
}
public class RemoteSkadiAnimator : MonoBehaviour
{
private Animator anim;
private Player player;
private void Start()
{
anim = GetComponent<Animator>();
if (anim == null) anim = GetComponentInChildren<Animator>();
player = GetComponentInParent<Player>();
}
private void Update()
{
if (anim == null || player == null) return;
bool flying = HarmonyLib.Traverse.Create(player).Field<bool>("m_flying").Value;
bool grounded = !flying && player.IsOnGround();
anim.SetBool("onGround", grounded);
anim.SetBool("flying", flying);
Vector3 vel = player.GetVelocity();
vel.y = 0f;
anim.SetFloat("forward_speed", vel.magnitude);
}
}
[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
public static class SkadiSEManPatch
{