From d05cea7f083ef7482afa8056935ff8ce56f3d916 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 17 Oct 2026 20:24:43 +0200 Subject: [PATCH] fix(warvulture): strip dependents first, no more Can't remove Humanoid at startup The startup error came from WarVultureVisual.BuildTemplate, not from the Ravager costume: its passes tried Humanoid before CharacterDrop. Components another one still requires now wait for a later pass. --- JotunnModStub/ModelBorrow.cs | 2 +- JotunnModStub/WarVulture/WarVultureItem.cs | 1 + JotunnModStub/WarVulture/WarVultureVisual.cs | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/ModelBorrow.cs b/JotunnModStub/ModelBorrow.cs index 1bd8fd2..08a777b 100644 --- a/JotunnModStub/ModelBorrow.cs +++ b/JotunnModStub/ModelBorrow.cs @@ -157,7 +157,7 @@ namespace RacesOfValheim /// True if another component on the same GameObject names this one's type in a /// [RequireComponent]. - private static bool IsRequired(Component target) + public static bool IsRequired(Component target) { System.Type type = target.GetType(); foreach (Component other in target.GetComponents()) diff --git a/JotunnModStub/WarVulture/WarVultureItem.cs b/JotunnModStub/WarVulture/WarVultureItem.cs index 7b735fa..74fc487 100644 --- a/JotunnModStub/WarVulture/WarVultureItem.cs +++ b/JotunnModStub/WarVulture/WarVultureItem.cs @@ -229,6 +229,7 @@ namespace RacesOfValheim if (component is MeshFilter) continue; if (component is MeshRenderer) continue; if (component is SkinnedMeshRenderer) continue; + if (ModelBorrow.IsRequired(component)) continue; // a later pass, once its dependent is gone Object.DestroyImmediate(component); diff --git a/JotunnModStub/WarVulture/WarVultureVisual.cs b/JotunnModStub/WarVulture/WarVultureVisual.cs index cf42a91..1a944f9 100644 --- a/JotunnModStub/WarVulture/WarVultureVisual.cs +++ b/JotunnModStub/WarVulture/WarVultureVisual.cs @@ -118,6 +118,15 @@ namespace RacesOfValheim if (component == null) continue; if (IsKept(component)) continue; + // Not yet if something still requires it: Unity would refuse and log an error + // ("Can't remove Humanoid because CharacterDrop depends on it"). It goes on a + // later pass, once its dependent is gone. + if (ModelBorrow.IsRequired(component)) + { + stubborn++; + continue; + } + Object.DestroyImmediate(component); if (component == null) destroyedSomething = true;