From 43e6cabf882ca867f6b220850b10f1e67ba2c76f Mon Sep 17 00:00:00 2001 From: Alvin Meng Date: Sat, 27 Jul 2024 13:27:30 -0400 Subject: [PATCH] don't load invalid definitions --- Source/MaterialDef.cs | 5 ++++- Source/MaterialReplacement.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/MaterialDef.cs b/Source/MaterialDef.cs index 0745ea9..05b0bc7 100644 --- a/Source/MaterialDef.cs +++ b/Source/MaterialDef.cs @@ -45,7 +45,10 @@ public static void Load() var def = new MaterialDef(node); if (string.IsNullOrEmpty(def.name)) { Debug.LogError("[Shabby] material definition must have a valid name"); - } else { + } else if (!def.isValid) { + Debug.LogError($"[Shabby][MaterialDef {def.name}] removing invalid definition"); + } + else { items[def.name] = def; } } diff --git a/Source/MaterialReplacement.cs b/Source/MaterialReplacement.cs index 897087c..3cbb9a5 100644 --- a/Source/MaterialReplacement.cs +++ b/Source/MaterialReplacement.cs @@ -65,7 +65,7 @@ static void Postfix(ref GameObject __result, ConfigNode partCfg) foreach (ConfigNode node in partCfg.nodes) { if (node.name != replacementNodeName) continue; var replacement = new MaterialReplacement(node); - if (replacement.materialDef?.isValid == true) replacements.Add(replacement); + if (replacement.materialDef != null) replacements.Add(replacement); } // Apply blanket replacements or material name replacements.