Actually taking order into consideration

This commit is contained in:
Michał Dolaś 2022-11-09 20:26:50 +01:00
parent 42b4b6b6a4
commit 9fd8c35b46
2 changed files with 14 additions and 4 deletions

View File

@ -263,8 +263,18 @@ namespace StardewModdingAPI.Framework.ModLoading
// sort mods
IModMetadata[] allMods = mods.ToArray();
IModMetadata[] modsToLoadEarly = allMods.Where(m => modIdsToLoadEarly.Contains(m.Manifest.UniqueID) && !modIdsToLoadLate.Contains(m.Manifest.UniqueID)).ToArray();
IModMetadata[] modsToLoadLate = allMods.Where(m => modIdsToLoadLate.Contains(m.Manifest.UniqueID) && !modIdsToLoadEarly.Contains(m.Manifest.UniqueID)).ToArray();
IModMetadata[] modsToLoadEarly = modIdsToLoadEarly
.Where(modId => !modIdsToLoadLate.Contains(modId))
.Select(modId => allMods.FirstOrDefault(m => m.Manifest.UniqueID == modId))
.Where(m => m != null)
.Select(m => m!)
.ToArray();
IModMetadata[] modsToLoadLate = modIdsToLoadLate
.Where(modId => !modIdsToLoadEarly.Contains(modId))
.Select(modId => allMods.FirstOrDefault(m => m.Manifest.UniqueID == modId))
.Where(m => m != null)
.Select(m => m!)
.ToArray();
IModMetadata[] modsToLoadAsUsual = allMods.Where(m => !modsToLoadEarly.Contains(m) && !modsToLoadLate.Contains(m)).ToArray();
List<IModMetadata> orderSortedMods = new();

View File

@ -426,10 +426,10 @@ namespace StardewModdingAPI.Framework
// warn about mods that should load early or late which are not found at all, or both
foreach (string modId in this.Settings.ModsToLoadEarly)
if (!mods.Any(m => m.Manifest.UniqueID == modId))
this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load early, but it could not be found.", LogLevel.Warn);
this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load early, but it could not be found or was skipped.", LogLevel.Warn);
foreach (string modId in this.Settings.ModsToLoadLate)
if (!mods.Any(m => m.Manifest.UniqueID == modId))
this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load late, but it could not be found.", LogLevel.Warn);
this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load late, but it could not be found or was skipped.", LogLevel.Warn);
foreach (string modId in this.Settings.ModsToLoadEarly)
if (this.Settings.ModsToLoadLate.Contains(modId))
this.Monitor.Log($" SMAPI configuration specifies a mod {modId} that should load both early and late - this will be ignored.", LogLevel.Warn);