コード例 #1
0
        public void ProcessModDependencies()
        {
            // Phase 1 - Set object inter-dependencies...
            Mods
            .ToList().ForEach(
                mod =>
            {
                mod.ConflictsWithMods = EnabledMods.Where(mod1 => mod.ConflictsWithModNames.Contains(mod1.Name))
                                        .ToList();
                var conflictingMods = mod.ConflictsWithMods.Select(mod1 => mod1.Name);
                conflictingMods.ToList()
                .ForEach(s => mod.InvalidReasonList.Add($"Conflicting dependency [{s}]"));

                mod.OptionallyDependsOnMods = EnabledMods
                                              .Where(mod1 => mod.OptionallyDependsOnModNames.Contains(mod1.Name)).ToList();

                mod.DependsOnMods = EnabledMods.Where(mod1 => mod.DependsOnModNames.Contains(mod1.Name))
                                    .ToList();
                var missingDependencies =
                    mod.DependsOnModNames.Except(mod.DependsOnMods.Select(mod1 => mod1.Name));
                missingDependencies.ToList()
                .ForEach(s => mod.InvalidReasonList.Add($"Missing dependency [{s}]"));

                mod.IsValid = !mod.InvalidReasonList.Any();
            });

            // Phase 2 - Check each mods dependency validity. We can only do this after setting Mod inter-dependency in phase 1
            Mods
            .Where(mod => mod.DependsOnMods.Any())
            .ToList().ForEach(
                mod =>
            {
                var dependencyTree = GetModDependenciesWithLevel(mod, 1, null);
                dependencyTree.Sort((o, o1) => o1.level.CompareTo(o.level));

                var invalidDependencies = dependencyTree.Where(o => !o.mod.IsValid).Select(o => o.mod.Name);
                invalidDependencies.ToList()
                .ForEach(s => mod.InvalidReasonList.Add($"Dependency [{s}] is invalid."));

                var disabledDependencies = dependencyTree.Where(o => !o.mod.Enabled).Select(o => o.mod.Name);
                disabledDependencies.ToList()
                .ForEach(s => mod.InvalidReasonList.Add($"Dependency [{s}] is disabled."));

                mod.IsValid = !mod.InvalidReasonList.Any();
            });
        }
コード例 #2
0
        public void Init()
        {
            var backup = Application.StartupPath + "/Backups/";

            Instance.BackupFolder = backup;

            Mods.Clear();
            if (Directory.Exists(Instance.ModFolder))
            {
                var dirs = Directory.GetDirectories(Instance.ModFolder);
                foreach (var d in dirs)
                {
                    var mod = ModInfo.Create(d);

                    if (mod == null)
                    {
                        continue;
                    }

                    mod.Enabled = EnabledMods == null || EnabledMods.Contains(mod.Name);
                    Mods.Add(mod);
                }
            }
        }
コード例 #3
0
        public void ProcessModLoadOrder()
        {
            var remainingModsToLoad = EnabledMods.Where(mod => mod.IsValid).ToList();
            var modsLoaded          = new List <Mod>(remainingModsToLoad.Count());
            var loadOrder           = 0;
            var loadCycle           = 0;

            while (remainingModsToLoad.Any())
            {
                loadCycle += 1;
                var modsToLoad = remainingModsToLoad
                                 .Where(mod => mod.DependsOnMods.All(mod1 => modsLoaded.Contains(mod1)) && mod
                                        .OptionallyDependsOnMods.Where(mod2 => mod2.IsValid)
                                        .All(mod2 => modsLoaded.Contains(mod2)))
                                 .OrderBy(mod => mod.Name).ToList();
                modsToLoad.ForEach(mod =>
                {
                    mod.LoadOrder = ++loadOrder;
                    mod.LoadCycle = loadCycle;
                    modsLoaded.Add(mod);
                    remainingModsToLoad.Remove(mod);
                });
            }
        }
コード例 #4
0
 public Mod GetFirstMod() => EnabledMods.FirstOrDefault(x => !(x is LocalMod)) ?? EnabledMods.FirstOrDefault();
コード例 #5
0
ファイル: ApiScore.cs プロジェクト: wwwMADwww/osuElements
        public ScoreRank CalculateScoreRank()
        {
            var accuracy = CalculateAccuracy();

            if (accuracy == 0)
            {
                return(D);
            }
            switch (GameMode)
            {
            default:
                var count300 = 1f * Count300 / MaxHitCount;
                var count50  = 1f * Count50 / MaxHitCount;
                if (count300 == 1)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight) ? XH : X);
                }
                if (Perfect && count300 > 0.9 && count50 < 0.01)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight) ? SH : S);
                }
                if (count300 > 0.9 || count300 > 0.8 && Perfect)
                {
                    return(A);
                }
                if (count300 > 0.8 || count300 > 0.7 && Perfect)
                {
                    return(B);
                }
                if (count300 > 0.6)
                {
                    return(C);
                }
                break;

            case Mania:
                if (accuracy == 1)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight | FadeIn) ? XH : X);
                }
                if (accuracy < 0.95)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight | FadeIn) ? SH : S);
                }
                if (accuracy > 0.9)
                {
                    return(A);
                }
                if (accuracy > 0.8)
                {
                    return(B);
                }
                if (accuracy > 0.7)
                {
                    return(C);
                }
                break;

            case CatchTheBeat:
                if (accuracy == 1)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight) ? XH : X);
                }
                if (accuracy < 0.98)
                {
                    return(EnabledMods.IsType(Hidden | Flashlight) ? SH : S);
                }
                if (accuracy > 0.94)
                {
                    return(A);
                }
                if (accuracy > 0.9)
                {
                    return(B);
                }
                if (accuracy > 0.85)
                {
                    return(C);
                }
                break;
            }
            return(D);
        }