fix(skeleton): stop the burning skull's torch clone falling off

The head-flame VFX clones only the source torch's ParticleSystem subtree,
then stripped components with a blocklist (every MonoBehaviour, every
Collider) to leave a bare flame. The blocklist missed Rigidbody - not a
MonoBehaviour in Unity - so a torch whose fire-particle node carried one kept
being acted on by physics independently of the parent GameObject that tracks
the head each frame, and visibly fell away from the skull.

Switched to an allowlist: keep only Transform/ParticleSystem/
ParticleSystemRenderer/Light, destroy everything else on the clone. Can't
miss a component type this way, whatever it turns out to be next.
This commit is contained in:
kanym 2026-08-07 10:13:00 +02:00
commit fc6cd4f4d4

View file

@ -213,15 +213,21 @@ namespace RacesOfValheim
light.intensity *= 0.6f;
}
// Anything that made the source a torch rather than a fire.
foreach (MonoBehaviour comp in m_instance.GetComponentsInChildren<MonoBehaviour>(true))
// Allowlist, not a blocklist: keep only what a pure VFX actually needs (the
// particle systems, their renderers, and the light tweaked above) and destroy
// every other component, whatever it turns out to be. A blocklist of "known bad"
// types (MonoBehaviour, Collider) missed Rigidbody - not a MonoBehaviour in Unity,
// so the old loop never touched it - and a torch's fire-particle node carrying one
// meant physics kept acting on the clone independently of m_instance being
// repositioned onto the head every frame: it visibly fell away while the empty
// parent stayed correctly tracked above it. Anything that made the source a torch
// rather than a bare flame - the stick mesh, ItemDrop, durability, all of it -
// goes the same way.
foreach (Component comp in m_instance.GetComponentsInChildren<Component>(true))
{
if (comp is Transform || comp is ParticleSystem || comp is ParticleSystemRenderer || comp is Light) continue;
Object.Destroy(comp);
}
foreach (Collider col in m_instance.GetComponentsInChildren<Collider>(true))
{
Object.Destroy(col);
}
return true;
}