public static void ParseAndProcessXML(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup)
        {
            XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes;

            for (int i = 0; i < childNodes.Count; i++)
            {
                if (childNodes[i].NodeType == XmlNodeType.Element)
                {
                    LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(childNodes[i], null);
                    XmlInheritance.TryRegister(childNodes[i], (loadableXmlAsset == null) ? null : loadableXmlAsset.mod);
                }
            }
            XmlInheritance.Resolve();
            DefPackage     defPackage     = new DefPackage("Unknown", string.Empty);
            ModContentPack modContentPack = LoadedModManager.runningMods.FirstOrDefault <ModContentPack>();

            modContentPack.AddDefPackage(defPackage);
            foreach (XmlNode xmlNode in xmlDoc.DocumentElement.ChildNodes)
            {
                LoadableXmlAsset loadableXmlAsset2 = assetlookup.TryGetValue(xmlNode, null);
                DefPackage       defPackage2       = (loadableXmlAsset2 == null) ? defPackage : loadableXmlAsset2.defPackage;
                Def def = DirectXmlLoader.DefFromNode(xmlNode, loadableXmlAsset2);
                if (def != null)
                {
                    def.modContentPack = ((loadableXmlAsset2 == null) ? modContentPack : loadableXmlAsset2.mod);
                    defPackage2.AddDef(def);
                }
            }
        }
Exemple #2
0
 public static void TryRegisterAllFrom(LoadableXmlAsset xmlAsset, ModContentPack mod)
 {
     if (xmlAsset.xmlDoc != null)
     {
         XmlNodeList childNodes = xmlAsset.xmlDoc.DocumentElement.ChildNodes;
         for (int i = 0; i < childNodes.Count; i++)
         {
             if (childNodes[i].NodeType == XmlNodeType.Element)
             {
                 XmlInheritance.TryRegister(childNodes[i], mod);
             }
         }
     }
 }
        public static void ParseAndProcessXML(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup)
        {
            XmlNodeList childNodes = xmlDoc.DocumentElement.ChildNodes;

            for (int i = 0; i < childNodes.Count; i++)
            {
                if (childNodes[i].NodeType == XmlNodeType.Element)
                {
                    LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(childNodes[i], null);
                    XmlInheritance.TryRegister(childNodes[i], (loadableXmlAsset == null) ? null : loadableXmlAsset.mod);
                }
            }
            XmlInheritance.Resolve();
            DefPackage     defPackage     = new DefPackage("(unknown)", "(unknown)");
            ModContentPack modContentPack = LoadedModManager.runningMods.FirstOrDefault <ModContentPack>();

            modContentPack.AddDefPackage(defPackage);
            IEnumerator enumerator = xmlDoc.DocumentElement.ChildNodes.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object           obj               = enumerator.Current;
                    XmlNode          xmlNode           = (XmlNode)obj;
                    LoadableXmlAsset loadableXmlAsset2 = assetlookup.TryGetValue(xmlNode, null);
                    DefPackage       defPackage2       = (loadableXmlAsset2 == null) ? defPackage : loadableXmlAsset2.defPackage;
                    Def def = DirectXmlLoader.DefFromNode(xmlNode, loadableXmlAsset2);
                    if (def != null)
                    {
                        def.modContentPack = ((loadableXmlAsset2 == null) ? modContentPack : loadableXmlAsset2.mod);
                        defPackage2.AddDef(def);
                    }
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
Exemple #4
0
        public static void ParseAndProcessXML(XmlDocument xmlDoc, Dictionary <XmlNode, LoadableXmlAsset> assetlookup)
        {
            XmlNodeList    childNodes = xmlDoc.DocumentElement.ChildNodes;
            List <XmlNode> list       = new List <XmlNode>();

            foreach (object item in childNodes)
            {
                list.Add(item as XmlNode);
            }
            DeepProfiler.Start("Loading asset nodes " + list.Count);
            try
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].NodeType == XmlNodeType.Element)
                    {
                        LoadableXmlAsset value = null;
                        DeepProfiler.Start("assetlookup.TryGetValue");
                        try
                        {
                            assetlookup.TryGetValue(list[i], out value);
                        }
                        finally
                        {
                            DeepProfiler.End();
                        }
                        DeepProfiler.Start("XmlInheritance.TryRegister");
                        try
                        {
                            XmlInheritance.TryRegister(list[i], value?.mod);
                        }
                        finally
                        {
                            DeepProfiler.End();
                        }
                    }
                }
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("XmlInheritance.Resolve()");
            try
            {
                XmlInheritance.Resolve();
            }
            finally
            {
                DeepProfiler.End();
            }
            runningMods.FirstOrDefault();
            DeepProfiler.Start("Loading defs for " + list.Count + " nodes");
            try
            {
                foreach (XmlNode item2 in list)
                {
                    LoadableXmlAsset loadableXmlAsset = assetlookup.TryGetValue(item2);
                    Def def = DirectXmlLoader.DefFromNode(item2, loadableXmlAsset);
                    if (def != null)
                    {
                        ModContentPack modContentPack = loadableXmlAsset?.mod;
                        if (modContentPack != null)
                        {
                            modContentPack.AddDef(def, loadableXmlAsset.name);
                        }
                        else
                        {
                            patchedDefs.Add(def);
                        }
                    }
                }
            }
            finally
            {
                DeepProfiler.End();
            }
        }