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);
}