Beispiel #1
0
        public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new()
        {
            XmlInheritance.Clear();
            List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>();

            object[] textObjects = Resources.LoadAll <TextAsset>(folderPath);
            object[] array       = textObjects;
            for (int j = 0; j < array.Length; j++)
            {
                TextAsset        textAsset        = (TextAsset)array[j];
                LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, string.Empty, textAsset.text);
                XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null);
                assets.Add(loadableXmlAsset);
            }
            XmlInheritance.Resolve();
            for (int i = 0; i < assets.Count; i++)
            {
                using (IEnumerator <T> enumerator = DirectXmlLoader.AllGameItemsFromAsset <T>(assets[i]).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        T item = enumerator.Current;
                        yield return(item);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
            }
            XmlInheritance.Clear();
            yield break;
IL_0195:
            /*Error near IL_0196: Unexpected return in MoveNext()*/;
        }
        public static void LoadAllActiveMods()
        {
            XmlInheritance.Clear();
            int num = 0;

            foreach (ModMetaData item2 in ModsConfig.ActiveModsInLoadOrder.ToList())
            {
                DeepProfiler.Start("Initializing " + item2);
                if (!item2.RootDir.Exists)
                {
                    ModsConfig.SetActive(item2.Identifier, false);
                    Log.Warning("Failed to find active mod " + item2.Name + "(" + item2.Identifier + ") at " + item2.RootDir);
                    DeepProfiler.End();
                }
                else
                {
                    ModContentPack item = new ModContentPack(item2.RootDir, num, item2.Name);
                    num++;
                    LoadedModManager.runningMods.Add(item);
                    DeepProfiler.End();
                }
            }
            for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
            {
                ModContentPack modContentPack = LoadedModManager.runningMods[i];
                DeepProfiler.Start("Loading " + modContentPack + " content");
                modContentPack.ReloadContent();
                DeepProfiler.End();
            }
            foreach (Type item3 in typeof(Mod).InstantiableDescendantsAndSelf())
            {
                if (!LoadedModManager.runningModClasses.ContainsKey(item3))
                {
                    ModContentPack modContentPack2 = (from modpack in LoadedModManager.runningMods
                                                      where modpack.assemblies.loadedAssemblies.Contains(item3.Assembly)
                                                      select modpack).FirstOrDefault();
                    LoadedModManager.runningModClasses[item3] = (Mod)Activator.CreateInstance(item3, modContentPack2);
                }
            }
            for (int j = 0; j < LoadedModManager.runningMods.Count; j++)
            {
                ModContentPack modContentPack3 = LoadedModManager.runningMods[j];
                DeepProfiler.Start("Loading " + modContentPack3);
                modContentPack3.LoadDefs(LoadedModManager.runningMods.SelectMany((ModContentPack rm) => rm.Patches));
                DeepProfiler.End();
            }
            foreach (ModContentPack runningMod in LoadedModManager.runningMods)
            {
                foreach (PatchOperation patch in runningMod.Patches)
                {
                    patch.Complete(runningMod.Name);
                }
                runningMod.ClearPatchesCache();
            }
            XmlInheritance.Clear();
        }
        public static void LoadAllActiveMods()
        {
            XmlInheritance.Clear();
            LoadedModManager.InitializeMods();
            LoadedModManager.LoadModContent();
            LoadedModManager.CreateModClasses();
            List <LoadableXmlAsset> xmls = LoadedModManager.LoadModXML();
            Dictionary <XmlNode, LoadableXmlAsset> assetlookup = new Dictionary <XmlNode, LoadableXmlAsset>();
            XmlDocument xmlDoc = LoadedModManager.CombineIntoUnifiedXML(xmls, assetlookup);

            LoadedModManager.ApplyPatches(xmlDoc, assetlookup);
            LoadedModManager.ParseAndProcessXML(xmlDoc, assetlookup);
            LoadedModManager.ClearCachedPatches();
            XmlInheritance.Clear();
        }
Beispiel #4
0
        public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new()
        {
            XmlInheritance.Clear();
            List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>();

            object[] array = Resources.LoadAll <TextAsset>(folderPath);
            for (int j = 0; j < array.Length; j++)
            {
                TextAsset        textAsset        = (TextAsset)array[j];
                LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, "", textAsset.text);
                XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null);
                assets.Add(loadableXmlAsset);
            }
            XmlInheritance.Resolve();
            for (int i = 0; i < assets.Count; i++)
            {
                foreach (T item in AllGameItemsFromAsset <T>(assets[i]))
                {
                    yield return(item);
                }
            }
            XmlInheritance.Clear();
        }
        public static IEnumerable <T> LoadXmlDataInResourcesFolder <T>(string folderPath) where T : new()
        {
            XmlInheritance.Clear();
            List <LoadableXmlAsset> assets = new List <LoadableXmlAsset>();

            object[] textObjects = Resources.LoadAll <TextAsset>(folderPath);
            foreach (TextAsset textAsset in textObjects)
            {
                LoadableXmlAsset loadableXmlAsset = new LoadableXmlAsset(textAsset.name, string.Empty, textAsset.text);
                XmlInheritance.TryRegisterAllFrom(loadableXmlAsset, null);
                assets.Add(loadableXmlAsset);
            }
            XmlInheritance.Resolve();
            for (int i = 0; i < assets.Count; i++)
            {
                foreach (T item in DirectXmlLoader.AllGameItemsFromAsset <T>(assets[i]))
                {
                    yield return(item);
                }
            }
            XmlInheritance.Clear();
            yield break;
        }
        public static void LoadAllActiveMods()
        {
            XmlInheritance.Clear();
            int num = 0;

            foreach (ModMetaData current in ModsConfig.ActiveModsInLoadOrder.ToList <ModMetaData>())
            {
                DeepProfiler.Start("Initializing " + current);
                if (!current.RootDir.Exists)
                {
                    ModsConfig.SetActive(current.Identifier, false);
                    Log.Warning(string.Concat(new object[]
                    {
                        "Failed to find active mod ",
                        current.Name,
                        "(",
                        current.Identifier,
                        ") at ",
                        current.RootDir
                    }));
                    DeepProfiler.End();
                }
                else
                {
                    ModContentPack item = new ModContentPack(current.RootDir, num, current.Name);
                    num++;
                    LoadedModManager.runningMods.Add(item);
                    DeepProfiler.End();
                }
            }
            for (int i = 0; i < LoadedModManager.runningMods.Count; i++)
            {
                ModContentPack modContentPack = LoadedModManager.runningMods[i];
                DeepProfiler.Start("Loading " + modContentPack + " content");
                modContentPack.ReloadContent();
                DeepProfiler.End();
            }
            foreach (Type type in typeof(Mod).InstantiableDescendantsAndSelf())
            {
                if (!LoadedModManager.runningModClasses.ContainsKey(type))
                {
                    ModContentPack modContentPack2 = (from modpack in LoadedModManager.runningMods
                                                      where modpack.assemblies.loadedAssemblies.Contains(type.Assembly)
                                                      select modpack).FirstOrDefault <ModContentPack>();
                    LoadedModManager.runningModClasses[type] = (Mod)Activator.CreateInstance(type, new object[]
                    {
                        modContentPack2
                    });
                }
            }
            for (int j = 0; j < LoadedModManager.runningMods.Count; j++)
            {
                ModContentPack modContentPack3 = LoadedModManager.runningMods[j];
                DeepProfiler.Start("Loading " + modContentPack3);
                modContentPack3.LoadDefs(LoadedModManager.runningMods.SelectMany((ModContentPack rm) => rm.Patches));
                DeepProfiler.End();
            }
            foreach (ModContentPack current2 in LoadedModManager.runningMods)
            {
                foreach (PatchOperation current3 in current2.Patches)
                {
                    current3.Complete(current2.Name);
                }
                current2.ClearPatchesCache();
            }
            XmlInheritance.Clear();
        }
Beispiel #7
0
        public static void LoadAllActiveMods()
        {
            DeepProfiler.Start("XmlInheritance.Clear()");
            try
            {
                XmlInheritance.Clear();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("InitializeMods()");
            try
            {
                InitializeMods();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("LoadModContent()");
            try
            {
                LoadModContent();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("CreateModClasses()");
            try
            {
                CreateModClasses();
            }
            finally
            {
                DeepProfiler.End();
            }
            List <LoadableXmlAsset> xmls = null;

            DeepProfiler.Start("LoadModXML()");
            try
            {
                xmls = LoadModXML();
            }
            finally
            {
                DeepProfiler.End();
            }
            Dictionary <XmlNode, LoadableXmlAsset> assetlookup = new Dictionary <XmlNode, LoadableXmlAsset>();
            XmlDocument xmlDocument = null;

            DeepProfiler.Start("CombineIntoUnifiedXML()");
            try
            {
                xmlDocument = CombineIntoUnifiedXML(xmls, assetlookup);
            }
            finally
            {
                DeepProfiler.End();
            }
            TKeySystem.Clear();
            DeepProfiler.Start("TKeySystem.Parse()");
            try
            {
                TKeySystem.Parse(xmlDocument);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("ApplyPatches()");
            try
            {
                ApplyPatches(xmlDocument, assetlookup);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("ParseAndProcessXML()");
            try
            {
                ParseAndProcessXML(xmlDocument, assetlookup);
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("ClearCachedPatches()");
            try
            {
                ClearCachedPatches();
            }
            finally
            {
                DeepProfiler.End();
            }
            DeepProfiler.Start("XmlInheritance.Clear()");
            try
            {
                XmlInheritance.Clear();
            }
            finally
            {
                DeepProfiler.End();
            }
        }