示例#1
0
        private string Run_Program(AutoFailDetectorVm args, BackgroundWorker worker, DoWorkEventArgs _)
        {
            var reader  = EditorReaderStuff.GetFullEditorReaderOrNot();
            var editor  = EditorReaderStuff.GetNewestVersionOrNot(args.Paths[0], reader);
            var beatmap = editor.Beatmap;

            // Get approach time and radius of the 50 score hit window
            var ar = args.ApproachRateOverride == -1
                ? editor.Beatmap.Difficulty["ApproachRate"].DoubleValue
                : args.ApproachRateOverride;
            var approachTime = (int)Beatmap.ApproachRateToMs(ar);

            var od = args.OverallDifficultyOverride == -1
                ? editor.Beatmap.Difficulty["OverallDifficulty"].DoubleValue
                : args.OverallDifficultyOverride;
            var window50 = (int)Math.Ceiling(200 - 10 * od);

            // Start time and end time
            var mapStartTime = (int)beatmap.GetMapStartTime();
            var mapEndTime   = (int)beatmap.GetMapEndTime();
            var autoFailTime = (int)beatmap.GetAutoFailCheckTime();

            // Detect auto-fail
            var autoFailDetector = new Classes.Tools.AutoFailDetector(beatmap.HitObjects,
                                                                      mapStartTime, mapEndTime, autoFailTime,
                                                                      approachTime, window50, args.PhysicsUpdateLeniency);

            var autoFail = autoFailDetector.DetectAutoFail();

            if (worker != null && worker.WorkerReportsProgress)
            {
                worker.ReportProgress(33);
            }

            // Fix auto-fail
            if (args.GetAutoFailFix)
            {
                var placedFix = autoFailDetector.AutoFailFixDialogue(args.AutoPlaceFix);

                if (placedFix)
                {
                    editor.SaveFile();
                }
            }

            if (worker != null && worker.WorkerReportsProgress)
            {
                worker.ReportProgress(67);
            }

            // Set the timeline lists
            _unloadingObjects          = args.ShowUnloadingObjects ? autoFailDetector.UnloadingObjects : new List <double>();
            _potentialUnloadingObjects = args.ShowPotentialUnloadingObjects ? autoFailDetector.PotentialUnloadingObjects : new List <double>();
            _potentialDisruptors       = args.ShowPotentialDisruptors ? autoFailDetector.Disruptors : new List <double>();

            // Set end time for the timeline
            _endTimeMonitor = mapEndTime;

            // Complete progressbar
            if (worker != null && worker.WorkerReportsProgress)
            {
                worker.ReportProgress(100);
            }

            // Do stuff
            if (args.Quick)
            {
                RunFinished?.Invoke(this, new RunToolCompletedEventArgs(true, false));
            }

            return(autoFail ? $"{autoFailDetector.UnloadingObjects.Count} unloading objects detected and {autoFailDetector.PotentialUnloadingObjects.Count} potential unloading objects detected!" :
                   autoFailDetector.PotentialUnloadingObjects.Count > 0 ? $"No auto-fail, but {autoFailDetector.PotentialUnloadingObjects.Count} potential unloading objects detected." :
                   "No auto-fail detected.");
        }