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.
This commit is contained in:
parent
61a74320c5
commit
d05cea7f08
3 changed files with 11 additions and 1 deletions
|
|
@ -157,7 +157,7 @@ namespace RacesOfValheim
|
|||
|
||||
/// <summary>True if another component on the same GameObject names this one's type in a
|
||||
/// [RequireComponent].</summary>
|
||||
private static bool IsRequired(Component target)
|
||||
public static bool IsRequired(Component target)
|
||||
{
|
||||
System.Type type = target.GetType();
|
||||
foreach (Component other in target.GetComponents<Component>())
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue