Пример #1
0
        public void Update(AuroraVersion version, bool updateRemote = false, bool updateCache = false)
        {
            Log.Debug($"Updating mod registry, updateRemote={updateRemote} updateCache={updateCache}");

            var         mods   = GetLocalMods();
            IList <Mod> remote = new List <Mod>();

            if (updateRemote)
            {
                remote = GetModsFromMirrors();
            }

            foreach (var remoteMod in remote)
            {
                var existingMod = mods.SingleOrDefault(mod => mod.Name == remoteMod.Name);
                if (existingMod != null)
                {
                    var updatedDownloadList = existingMod.Downloads.ToList();
                    updatedDownloadList.AddRange(remoteMod.Downloads.Where(nd => !existingMod.Downloads.Any(ed => ed.Version == nd.Version)));
                    remoteMod.Downloads = updatedDownloadList;
                    mods.Remove(existingMod);
                    mods.Add(remoteMod);
                }
                else
                {
                    mods.Add(remoteMod);
                }
            }

            foreach (var mod in mods.ToList())
            {
                mod.Downloads.RemoveAll(d => !version.CompatibleWith(d.TargetAuroraVersion));
                if (mod.Downloads.Count == 0)
                {
                    mods.Remove(mod);
                }
            }

            Mods = mods;

            if (updateRemote && updateCache)
            {
                foreach (var mod in Mods.Where(mod => mod.Installed))
                {
                    mod.UpdateCache();
                }
            }
            else if (updateCache && !updateRemote)
            {
                throw new ArgumentException("Updating cache without updating remote does nothing");
            }
        }
Пример #2
0
 public ModVersion LatestInstalledVersionCompatibleWith(AuroraVersion auroraVersion) => Downloads.OrderByDescending(v => v.Version)
 .Where(v => v.Downloaded && auroraVersion.CompatibleWith(v.TargetAuroraVersion))
 .FirstOrDefault();