Esempio n. 1
0
        private static void LoadModContent(CancellationToken token, ref List <Mod> mods, Action <Mod> loadAction)
        {
            MemoryTracking.Checkpoint();
            int num = 0;

            foreach (var mod in ModLoader.Mods)
            {
                Interface.loadModsProgress.SetCurrentMod(num++, $"{mod.Name} v{mod.Version}");
                try {
                    if (!mods.Contains(mod))
                    {
                        mods.Add(mod);
                    }
                    token.ThrowIfCancellationRequested();
                    LoadingMod = mod;
                    loadAction(mod);
                    token.ThrowIfCancellationRequested();
                }
                catch (Exception e) {
                    e.Data["mods"] = mods.Select(x => x.Name).ToArray();
                    throw;
                }
                finally {
                    LoadingMod = null;
                    MemoryTracking.Update(mod.Name);
                }
            }
        }
Esempio n. 2
0
        internal static List <Mod> InstantiateMods(List <LocalMod> modsToLoad)
        {
            var modList = new List <LoadedMod>();

            foreach (var loading in modsToLoad)
            {
                if (!loadedMods.TryGetValue(loading.Name, out LoadedMod mod))
                {
                    mod = loadedMods[loading.Name] = new LoadedMod();
                }

                mod.SetMod(loading);
                modList.Add(mod);
            }

            RecalculateReferences();

#if !MONO       //as far as we know, mono doesn't support edit and continue anyway
            if (Debugger.IsAttached)
            {
                ModCompile.DeveloperMode = true;
                foreach (var mod in modList.Where(mod => mod.properties.editAndContinue && mod.CanEaC))
                {
                    mod.EnableEaC();
                }
            }
#endif

            try {
                //load all the assemblies in parallel.
                Interface.loadMods.SetLoadStage("tModLoader.MSSandboxing", modsToLoad.Count);
                int i = 0;
                Parallel.ForEach(modList, mod => {
                    Interface.loadMods.SetCurrentMod(i++, mod.Name);
                    mod.LoadAssemblies();
                });

                //Assemblies must be loaded before any instantiation occurs to satisfy dependencies
                Interface.loadMods.SetLoadStage("tModLoader.MSInstantiating");
                MemoryTracking.Checkpoint();
                return(modList.Select(Instantiate).ToList());
            }
            catch (AggregateException ae) {
                ae.Data["mods"] = ae.InnerExceptions.Select(e => (string)e.Data["mod"]).ToArray();
                throw;
            }
        }
Esempio n. 3
0
        private static void LoadModContent(Action <Mod> loadAction)
        {
            MemoryTracking.Checkpoint();
            int num = 0;

            foreach (var mod in ModLoader.Mods)
            {
                Interface.loadMods.SetCurrentMod(num++, mod.Name);
                try {
                    LoadingMod = mod;
                    loadAction(mod);
                }
                catch (Exception e) {
                    e.Data["mod"] = mod.Name;
                    throw;
                }
                finally {
                    LoadingMod = null;
                    MemoryTracking.Update(mod.Name);
                }
            }
        }
Esempio n. 4
0
        private static void LoadModContent(CancellationToken token, Action <Mod> loadAction)
        {
            MemoryTracking.Checkpoint();
            int num = 0;

            foreach (var mod in ModLoader.Mods)
            {
                token.ThrowIfCancellationRequested();
                Interface.loadMods.SetCurrentMod(num++, $"{mod.Name} v{mod.Version}");
                try {
                    LoadingMod = mod;
                    loadAction(mod);
                }
                catch (Exception e) {
                    e.Data["mod"] = mod.Name;
                    throw;
                }
                finally {
                    LoadingMod = null;
                    MemoryTracking.Update(mod.Name);
                }
            }
        }