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

@ -77,6 +77,10 @@ namespace RacesOfValheim
{
UpdateAswidVisuals();
}
else if (race == "Trol")
{
// Managed externally in TrolPatches.cs
}
else
{
RevertAllVisuals();
@ -230,44 +234,6 @@ namespace RacesOfValheim
$"[SkadiSync] remote '{m_player.GetPlayerName()}' form='{currentForm}' flying={flying} " +
$"y={m_player.transform.position.y:F1} gravity={(body != null ? body.useGravity.ToString() : "no-body")}");
}
if (currentForm != m_lastSkadiForm)
{
// Form changed
if (m_currentFormInstance != null) Destroy(m_currentFormInstance);
Transform playerVisual = m_player.transform.Find("Visual");
if (playerVisual != null)
{
if (string.IsNullOrEmpty(currentForm))
{
playerVisual.localScale = Vector3.one;
}
else
{
playerVisual.localScale = Vector3.one * 0.001f;
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(currentForm);
if (prefab != null)
{
Transform visual = prefab.transform.Find("Visual");
if (visual != null)
{
m_currentFormInstance = Instantiate(visual.gameObject, m_player.transform);
m_currentFormInstance.transform.localPosition = Vector3.zero;
m_currentFormInstance.transform.localRotation = Quaternion.identity;
Component animEvent = m_currentFormInstance.GetComponent("AnimEvent");
if (animEvent != null) Destroy(animEvent);
foreach (var col in m_currentFormInstance.GetComponentsInChildren<Collider>())
{
Destroy(col);
}
}
}
}
}
m_lastSkadiForm = currentForm;
}
}
private void RevertAllVisuals()