public static BodyPartRecord BodyPartFromNode(XmlNode node, string label, BodyPartRecord defaultValue) { if (node != null && Scribe.EnterNode(label)) { try { XmlAttribute xmlAttribute = node.Attributes["IsNull"]; if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true") { return(null); } BodyDef bodyDef = DefFromNode <BodyDef>(Scribe.loader.curXmlParent["body"]); if (bodyDef == null) { return(null); } XmlElement xmlElement = Scribe.loader.curXmlParent["index"]; int index = ((xmlElement != null) ? int.Parse(xmlElement.InnerText) : (-1)); index = BackCompatibility.GetBackCompatibleBodyPartIndex(bodyDef, index); return(bodyDef.GetPartAtIndex(index)); } finally { Scribe.ExitNode(); } } return(defaultValue); }