InstantiateMods() static private method

static private InstantiateMods ( List modsToLoad ) : List
modsToLoad List
return List
Ejemplo n.º 1
0
        public static List <Mod> LoadMods()
        {
            CommandLineModPackOverride();

            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift() || ModLoader.skipLoad)
            {
                ModLoader.skipLoad = false;
                modsToLoad.Clear();
                Interface.loadMods.SetLoadStage("Loading Cancelled");
            }

            VerifyNames(modsToLoad);

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad      = Sort(modsToLoad);
                dependencyCache = modsToLoad.ToDictionary(m => m.Name, m => m.properties.RefNames(false).ToList());
            }
            catch (ModSortingException e)
            {
                e.Data["mods"]           = e.errored.Select(m => m.Name).ToArray();
                e.Data["hideStackTrace"] = true;
                throw;
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }
Ejemplo n.º 2
0
        private static bool LoadMods()
        {
            //load all referenced assemblies before mods for compiling
            ModCompile.LoadReferences();

            if (!CommandLineModPackOverride())
            {
                return(false);
            }

            Interface.loadMods.SetProgressFinding();
            var modsToLoad = FindMods().Where(mod => IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift())
            {
                modsToLoad.Clear();
            }

            if (!VerifyNames(modsToLoad))
            {
                return(false);
            }

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad = Sort(modsToLoad);
            }
            catch (ModSortingException e)
            {
                foreach (var mod in e.errored)
                {
                    mod.Enabled = false;
                }

                ErrorLogger.LogDependencyError(e.Message);
                return(false);
            }

            var modInstances = AssemblyManager.InstantiateMods(modsToLoad);

            if (modInstances == null)
            {
                return(false);
            }

            modInstances.Insert(0, new ModLoaderMod());
            loadedMods = modInstances.ToArray();
            loadedModsWeakReferences = loadedMods.Skip(1).Select(x => new WeakReference(x)).ToArray();
            foreach (var mod in modInstances)
            {
                loadOrder.Push(mod.Name);
                mods[mod.Name] = mod;
            }

            return(true);
        }
Ejemplo n.º 3
0
        private static bool LoadMods()
        {
            //load all referenced assemblies before mods for compiling
            ModCompile.LoadReferences();

            Interface.loadMods.SetProgressFinding();
            var modsToLoad = FindMods()
                             .Where(IsEnabled)
                             .Select(mod => new LoadingMod(mod, BuildProperties.ReadModFile(mod)))
                             .Where(mod => LoadSide(mod.properties.side))
                             .ToList();

            if (!VerifyNames(modsToLoad))
            {
                return(false);
            }

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad = Sort(modsToLoad);
            }
            catch (ModSortingException e)
            {
                foreach (var mod in e.errored)
                {
                    DisableMod(mod.modFile);
                }

                ErrorLogger.LogDependencyError(e.Message);
                return(false);
            }

            var modInstances = AssemblyManager.InstantiateMods(modsToLoad);

            if (modInstances == null)
            {
                return(false);
            }

            modInstances.Insert(0, new ModLoaderMod());
            loadedMods = modInstances.ToArray();
            foreach (var mod in modInstances)
            {
                loadOrder.Push(mod.Name);
                mods[mod.Name] = mod;
            }

            return(true);
        }
Ejemplo n.º 4
0
        public static List <Mod> LoadMods()
        {
            //load all referenced assemblies before mods for compiling
            ModCompile.LoadReferences();

            if (!CommandLineModPackOverride())
            {
                return(null);
            }

            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift())
            {
                modsToLoad.Clear();
            }

            if (!VerifyNames(modsToLoad))
            {
                return(null);
            }

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad = Sort(modsToLoad);
            }
            catch (ModSortingException e)
            {
                foreach (var mod in e.errored)
                {
                    mod.Enabled = false;
                }

                ErrorLogger.LogDependencyError(e.Message);
                Main.menuMode = Interface.errorMessageID;
                return(null);
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }
Ejemplo n.º 5
0
        public static List <Mod> LoadMods()
        {
            CommandLineModPackOverride();

            // Alternate fix for updating enabled mods
            //foreach (string fileName in Directory.GetFiles(ModLoader.ModPath, "*.tmod.update", SearchOption.TopDirectoryOnly)) {
            //	File.Copy(fileName, Path.GetFileNameWithoutExtension(fileName), true);
            //	File.Delete(fileName);
            //}
            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift() || ModLoader.skipLoad)
            {
                ModLoader.skipLoad = false;
                modsToLoad.Clear();
                Interface.loadMods.SetLoadStage("Loading Cancelled");
            }

            VerifyNames(modsToLoad);

            try {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad      = Sort(modsToLoad);
                dependencyCache = modsToLoad.ToDictionary(m => m.Name, m => m.properties.RefNames(false).ToList());
            }
            catch (ModSortingException e) {
                e.Data["mods"]           = e.errored.Select(m => m.Name).ToArray();
                e.Data["hideStackTrace"] = true;
                throw;
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }