public static T DefFromNode <T>(XmlNode subNode) where T : Def, new() { if (subNode == null || subNode.InnerText == null || subNode.InnerText == "null") { return(null); } string text = BackCompatibility.BackCompatibleDefName(typeof(T), subNode.InnerText, forDefInjections: false, subNode); T namedSilentFail = DefDatabase <T> .GetNamedSilentFail(text); if (namedSilentFail == null && !BackCompatibility.WasDefRemoved(subNode.InnerText, typeof(T))) { if (text == subNode.InnerText) { Log.Error(string.Concat("Could not load reference to ", typeof(T), " named ", subNode.InnerText)); } else { Log.Error(string.Concat("Could not load reference to ", typeof(T), " named ", subNode.InnerText, " after compatibility-conversion to ", text)); } BackCompatibility.PostCouldntLoadDef(subNode.InnerText); } return(namedSilentFail); }