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