// Discover new mods. public void DiscoverMods() { NewMods.Clear(); ModDiscoveryStarted?.Invoke(); _mods.Clear(); BasePath.Refresh(); if (Valid && BasePath.Exists) { foreach (var modFolder in BasePath.EnumerateDirectories()) { var mod = LoadMod(modFolder); if (mod == null) { continue; } mod.Index = _mods.Count; _mods.Add(mod); } } ModDiscoveryFinished?.Invoke(); PluginLog.Information("Rediscovered mods."); }
// Add new mods to NewMods and remove deleted mods from NewMods. private void OnModPathChange(ModPathChangeType type, Mod mod, DirectoryInfo?oldDirectory, DirectoryInfo?newDirectory) { switch (type) { case ModPathChangeType.Added: NewMods.Add(mod); break; case ModPathChangeType.Deleted: NewMods.Remove(mod); break; } }