Exemplo n.º 1
0
        private async void ServiceDiffCalcRequest()
        {
            // acquire mutually exclusive entry into this method
            serviceDiffCalcRequestLocked = true;

            decimal stars = 0.0M, aim = 0.0M, speed = 0.0M;

            while (completedDiffCalcRequest == null || completedDiffCalcRequest.RequestNumber != diffCalcRequests.Last().RequestNumber)
            {
                completedDiffCalcRequest = diffCalcRequests.Last();
                try
                {
                    (stars, aim, speed) = await Task.Run(() => DifficultyCalculator.CalculateStarRating(NewBeatmap));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine("lol asdfasdf;lkjasdf");
                    (stars, aim, speed) = (0, 0, 0);
                }
                // if a new request came in, invalidate the diffcalc result and service the new request
            }
            // we serviced the last request, so we can commit to the diffcalc result
            StarRating  = stars;
            AimRating   = aim;
            SpeedRating = speed;
            BeatmapModified?.Invoke(this, EventArgs.Empty);

            serviceDiffCalcRequestLocked = false;
        }
Exemplo n.º 2
0
        public void SetBpmMultiplier(float multiplier)
        {
            BpmMultiplier = multiplier;

            // make no changes
            if (State == EditorState.NOT_READY)
            {
                return;
            }

            // scale AR
            if (ScaleAR && !ArIsLocked)
            {
                NewBeatmap.ApproachRate = DifficultyCalculator.CalculateMultipliedAR(OriginalBeatmap, BpmMultiplier);
            }

            // scale OD
            if (ScaleOD && !OdIsLocked)
            {
                NewBeatmap.OverallDifficulty = DifficultyCalculator.CalculateMultipliedOD(OriginalBeatmap, BpmMultiplier);
            }

            // modify beatmap timing
            ModifyBeatmapTiming(OriginalBeatmap, NewBeatmap, BpmMultiplier);

            RequestDiffCalc();
            BeatmapModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 3
0
 public void SetHPLock(bool locked)
 {
     HpIsLocked = locked;
     if (!locked)
     {
         NewBeatmap.HPDrainRate = OriginalBeatmap.HPDrainRate;
         BeatmapModified?.Invoke(this, EventArgs.Empty);
     }
     ControlsModified?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 4
0
 public void SetCSLock(bool locked)
 {
     CsIsLocked = locked;
     if (!locked)
     {
         NewBeatmap.CircleSize = OriginalBeatmap.CircleSize;
         BeatmapModified?.Invoke(this, EventArgs.Empty);
     }
     ControlsModified?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 5
0
        public void SetHP(float value)
        {
            if (State != EditorState.READY)
            {
                return;
            }

            NewBeatmap.HPDrainRate = value;
            lockedHP = value;
            BeatmapModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 6
0
        public void SetCS(float value)
        {
            if (State != EditorState.READY)
            {
                return;
            }

            NewBeatmap.CircleSize = value;
            lockedCS = value;
            RequestDiffCalc();
            BeatmapModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 7
0
        public void SetOD(float value)
        {
            if (State != EditorState.READY)
            {
                return;
            }

            NewBeatmap.OverallDifficulty = value;
            if (OdIsLocked)
            {
                lockedOD = value;
            }

            ScaleOD = false;
            BeatmapModified?.Invoke(this, EventArgs.Empty);
            ControlsModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 8
0
        public void SetScaleOD(bool value)
        {
            ScaleOD = value;

            if (State == EditorState.NOT_READY)
            {
                return;
            }

            if (ScaleOD)
            {
                NewBeatmap.OverallDifficulty = DifficultyCalculator.CalculateMultipliedOD(OriginalBeatmap, BpmMultiplier);
                BeatmapModified?.Invoke(this, EventArgs.Empty);
            }
            ArIsLocked = false;
            ControlsModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 9
0
        public void SetAR(float value)
        {
            if (State != EditorState.READY)
            {
                return;
            }

            NewBeatmap.ApproachRate = value;
            if (ArIsLocked)
            {
                lockedAR = value;
            }

            ScaleAR = false;
            BeatmapModified?.Invoke(this, EventArgs.Empty);
            ControlsModified?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 10
0
 public void ResetBeatmap()
 {
     NewBeatmap.HPDrainRate       = OriginalBeatmap.HPDrainRate;
     NewBeatmap.CircleSize        = OriginalBeatmap.CircleSize;
     NewBeatmap.ApproachRate      = OriginalBeatmap.ApproachRate;
     NewBeatmap.OverallDifficulty = OriginalBeatmap.OverallDifficulty;
     HpIsLocked    = false;
     CsIsLocked    = false;
     ArIsLocked    = false;
     OdIsLocked    = false;
     ScaleAR       = true;
     ScaleOD       = true;
     BpmMultiplier = 1.0f;
     ModifyBeatmapTiming(OriginalBeatmap, NewBeatmap, 1.0f);
     RequestDiffCalc();
     ControlsModified?.Invoke(this, EventArgs.Empty);
     BeatmapModified?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 11
0
        private async void ServiceBeatmapChangeRequest()
        {
            // acquire mutually exclusive entry into this method
            serviceBeatmapRequestLocked = true;

            Beatmap candidateOriginalBeatmap = null, candidateNewBeatmap = null;

            while (completedBeatmapRequest == null || completedBeatmapRequest.RequestNumber != mapChangeRequests.Last().RequestNumber)
            {
                completedBeatmapRequest  = mapChangeRequests.Last();
                candidateOriginalBeatmap = await Task.Run(() => LoadBeatmap(mapChangeRequests.Last().Name));

                if (candidateOriginalBeatmap != null)
                {
                    candidateNewBeatmap = new Beatmap(candidateOriginalBeatmap);
                }

                // if a new request came in, invalidate candidate beatmap and service the new request
            }

            // no new requests, we can commit to using this beatmap
            OriginalBeatmap = candidateOriginalBeatmap;
            NewBeatmap      = candidateNewBeatmap;
            if (OriginalBeatmap == null)
            {
                SetState(EditorState.NOT_READY);
                NotReadyReason = BadBeatmapReason.ERROR_LOADING_BEATMAP;
                BeatmapSwitched?.Invoke(this, EventArgs.Empty);
            }
            else
            {
                if (OriginalBeatmap.HitObjectCount == 0)
                {
                    SetState(EditorState.NOT_READY);
                    NotReadyReason = BadBeatmapReason.EMPTY_MAP;
                    BeatmapSwitched?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    // Apply multiplier
                    if (BpmIsLocked)
                    {
                        SetBpm(lockedBpm);
                    }
                    NewBeatmap.SetRate(BpmRate);

                    // Apply bpm scaled settings
                    if (ScaleAR)
                    {
                        NewBeatmap.ApproachRate = DifficultyCalculator.CalculateMultipliedAR(candidateOriginalBeatmap, BpmRate);
                    }
                    if (ScaleOD)
                    {
                        NewBeatmap.OverallDifficulty = DifficultyCalculator.CalculateMultipliedOD(candidateOriginalBeatmap, BpmRate);
                    }

                    // Apply locked settings to new map
                    if (HpIsLocked)
                    {
                        NewBeatmap.HPDrainRate = lockedHP;
                    }
                    if (CsIsLocked)
                    {
                        NewBeatmap.CircleSize = lockedCS;
                    }
                    if (ArIsLocked)
                    {
                        NewBeatmap.ApproachRate = lockedAR;
                    }
                    if (OdIsLocked)
                    {
                        NewBeatmap.OverallDifficulty = lockedOD;
                    }

                    // Apply Hardrock
                    if (ForceHardrockCirclesize)
                    {
                        NewBeatmap.CircleSize = OriginalBeatmap.CircleSize * 1.3M;
                    }

                    SetState(EditorState.READY);
                    RequestDiffCalc();
                    BeatmapSwitched?.Invoke(this, EventArgs.Empty);
                    BeatmapModified?.Invoke(this, EventArgs.Empty);
                }
            }
            ControlsModified?.Invoke(this, EventArgs.Empty);
            serviceBeatmapRequestLocked = false;
        }
Exemplo n.º 12
0
 public void ForceEventBeatmapModified() => BeatmapModified?.Invoke(this, EventArgs.Empty);