LoadReferences() static private method

static private LoadReferences ( ) : void
return void
Ejemplo n.º 1
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.º 2
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.º 3
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));
        }