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); }
public static void Look <T>(ref T value, string label) where T : Def, new() { if (Scribe.mode == LoadSaveMode.Saving) { string text; if (value == null) { text = "null"; } else { text = value.defName; } Scribe_Values.Look <string>(ref text, label, "null", false); } else if (Scribe.mode == LoadSaveMode.LoadingVars) { value = ScribeExtractor.DefFromNode <T>(Scribe.loader.curXmlParent[label]); } }