Exclude requested mods that are also in the world
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Reflection.Emit;
|
||||
using HarmonyLib;
|
||||
using Plugin.ClientModLoader.Utils;
|
||||
using Sandbox.Definitions;
|
||||
using Sandbox.Engine.Networking;
|
||||
using Sandbox.Game.World;
|
||||
@@ -29,11 +30,11 @@ internal static class ModInjector
|
||||
{
|
||||
var worldMods = __state.Select(b => b.PublishedFileId).ToImmutableHashSet();
|
||||
var resolvedMods = mods.ToImmutableDictionary(b => b.PublishedFileId);
|
||||
|
||||
|
||||
// list of selected mods which are resolved
|
||||
var requestedMods = mods.IntersectBy(Mods, b => b.PublishedFileId)
|
||||
var requestedMods = mods.IntersectBy(Mods, b => b.PublishedFileId).ExceptBy(worldMods, b => b.PublishedFileId)
|
||||
.ToDictionary(b => b.PublishedFileId);
|
||||
|
||||
|
||||
// add dependencies of requested mods
|
||||
// but skip if those are also requested by world we're loading in
|
||||
foreach (var dependency in requestedMods.Values
|
||||
@@ -42,13 +43,13 @@ internal static class ModInjector
|
||||
{
|
||||
if (worldMods.Contains(dependency))
|
||||
continue;
|
||||
|
||||
|
||||
requestedMods.TryAdd(dependency, resolvedMods[dependency]);
|
||||
}
|
||||
|
||||
|
||||
// add resolved client mods and their exclusive dependencies
|
||||
AdditionalFilledModItems.AddRange(requestedMods.Values);
|
||||
|
||||
|
||||
// upsert world mods by resolved ones excluding our client ones and their exclusive dependencies
|
||||
// so world mods is only populated by dependencies of original world mods
|
||||
foreach (var mod in mods.ExceptBy(requestedMods.Keys, b => b.PublishedFileId))
|
||||
|
Reference in New Issue
Block a user