예제 #1
0
        public void Reset(OsuBeatmap beatmap)
        {
            this.beatmap = beatmap;

            hitWindow50  = osuManager.HitWindow50(beatmap.OverallDifficulty);
            hitWindow100 = osuManager.HitWindow100(beatmap.OverallDifficulty);
            hitWindow300 = osuManager.HitWindow300(beatmap.OverallDifficulty);

            var mods = osuManager.Player.HitObjectManager.CurrentMods;

            audioRate = mods.HasFlag(Mods.HalfTime) ? 0.75f : mods.HasFlag(Mods.DoubleTime) ? 1.5f : 1;

            minOffset          = calculateTimingOffset(configManager.HitTimingsMinOffset);
            maxOffset          = calculateTimingOffset(configManager.HitTimingsMaxOffset);
            minAlternateOffset = calculateTimingOffset(configManager.HitTimingsAlternateMinOffset);
            maxAlternateOffset = calculateTimingOffset(configManager.HitTimingsAlternateMaxOffset);

            hitObjectRadius = osuManager.HitObjectRadius(beatmap.CircleSize);
            missRadius      = configManager.HitScanMissRadius;

            canMiss            = false;
            lastHitScanIndex   = -1;
            lastOnNotePosition = null;
        }
예제 #2
0
파일: Relax.cs 프로젝트: Lala-sama/osu-rx
        public void Start()
        {
            shouldStop     = false;
            currentBeatmap = osuManager.CurrentBeatmap;
            primaryKey     = configManager.PrimaryKey;
            secondaryKey   = configManager.SecondaryKey;

            hitScanEnabled           = configManager.EnableHitScan;
            holdBeforeSpinnerTime    = configManager.HoldBeforeSpinnerTime;
            hitScanPredictionEnabled = configManager.EnableHitScanPrediction;
            hitScanRadiusMultiplier  = configManager.HitScanRadiusMultiplier;
            hitScanMaxDistance       = configManager.HitScanMaxDistance;
            hitScanRadiusAdditional  = configManager.HitScanRadiusAdditional;

            var   playStyle   = configManager.PlayStyle;
            var   hit100Key   = configManager.HitWindow100Key;
            float audioRate   = (osuManager.CurrentMods.HasFlag(Mods.DoubleTime) || osuManager.CurrentMods.HasFlag(Mods.Nightcore)) ? 1.5f : osuManager.CurrentMods.HasFlag(Mods.HalfTime) ? 0.75f : 1f;
            float maxBPM      = configManager.MaxSingletapBPM / (audioRate / 2);
            int   audioOffset = configManager.AudioOffset;

            hitWindow50  = osuManager.HitWindow50(currentBeatmap.DifficultySection.OverallDifficulty);
            hitWindow100 = osuManager.HitWindow100(currentBeatmap.DifficultySection.OverallDifficulty);
            hitWindow300 = osuManager.HitWindow300(currentBeatmap.DifficultySection.OverallDifficulty);

            int            index, lastRetryCount, hitTime = 0;
            bool           isHit, shouldStartAlternating, shouldAlternate;
            VirtualKeyCode currentKey;
            HitObject      currentHitObject;

            (int StartOffset, int HoldTime)currentHitTimings;

            reset();

            while (osuManager.CanPlay && index < currentBeatmap.HitObjects.Count && !shouldStop)
            {
                Thread.Sleep(1);

                if (osuManager.IsPaused)
                {
                    if (isHit)
                    {
                        isHit = false;
                        releaseAllKeys();
                    }

                    continue;
                }

                if (osuManager.RetryCount != lastRetryCount)
                {
                    reset(true);
                    releaseAllKeys();
                    continue;
                }

                int currentTime = osuManager.CurrentTime + audioOffset;
                if (currentTime >= currentHitObject.StartTime - hitWindow50)
                {
                    var hitScanResult = getHitScanResult(index);
                    if (!isHit && ((currentTime >= currentHitObject.StartTime + currentHitTimings.StartOffset && hitScanResult == HitScanResult.CanHit) || hitScanResult == HitScanResult.ShouldHit))
                    {
                        isHit   = true;
                        hitTime = currentTime;

                        switch (playStyle)
                        {
                        case PlayStyles.MouseOnly when currentKey == primaryKey:
                            inputSimulator.Mouse.LeftButtonDown();
                            break;

                        case PlayStyles.MouseOnly:
                            inputSimulator.Mouse.RightButtonDown();
                            break;

                        case PlayStyles.TapX when !shouldAlternate && !shouldStartAlternating:
                            inputSimulator.Mouse.LeftButtonDown();
                            currentKey = primaryKey;
                            break;

                        default:
                            inputSimulator.Keyboard.KeyDown(currentKey);
                            break;
                        }
                    }
                    else if (isHit && currentTime >= (currentHitObject is HitCircle ? hitTime : currentHitObject.EndTime) + currentHitTimings.HoldTime)
                    {
                        moveToNextObject();

                        if (currentHitObject is Spinner && currentHitObject.StartTime - currentBeatmap.HitObjects[index - 1].EndTime <= holdBeforeSpinnerTime)
                        {
                            continue;
                        }

                        isHit = false;
                        releaseAllKeys();
                    }
                    else if (!isHit && hitScanResult == HitScanResult.Wait && currentTime >= (currentHitObject is HitCircle ? currentHitObject.StartTime : currentHitObject.EndTime + hitWindow50))
                    {
                        moveToNextObject();
                    }
                }
            }

            releaseAllKeys();

            while (osuManager.CanPlay && index >= currentBeatmap.HitObjects.Count && !shouldStop)
            {
                Thread.Sleep(5);
            }

            void reset(bool retry = false)
            {
                index            = retry ? 0 : closestHitObjectIndex;
                isHit            = false;
                currentKey       = primaryKey;
                currentHitObject = currentBeatmap.HitObjects[index];
                updateAlternate();
                currentHitTimings = randomizeHitObjectTimings(index, shouldAlternate, false);
                lastRetryCount    = osuManager.RetryCount;
            }

            void updateAlternate()
            {
                var lastHitObject = index > 0 ? currentBeatmap.HitObjects[index - 1] : null;
                var nextHitObject = index + 1 < currentBeatmap.HitObjects.Count ? currentBeatmap.HitObjects[index + 1] : null;

                // This is to fix possible divide by zero exception's

                shouldStartAlternating = nextHitObject != null ? 60000 / (nextHitObject.StartTime - currentHitObject.EndTime) >= maxBPM : false;
                shouldAlternate        = lastHitObject != null ? 60000 / (currentHitObject.StartTime - lastHitObject.EndTime) >= maxBPM : false;
                if (shouldAlternate || playStyle == PlayStyles.Alternate)
                {
                    currentKey = (currentKey == primaryKey) ? secondaryKey : primaryKey;
                }
                else
                {
                    currentKey = primaryKey;
                }
            }

            void moveToNextObject()
            {
                index++;
                if (index < currentBeatmap.HitObjects.Count)
                {
                    currentHitObject = currentBeatmap.HitObjects[index];

                    updateAlternate();
                    currentHitTimings = randomizeHitObjectTimings(index, shouldAlternate, inputSimulator.InputDeviceState.IsKeyDown(hit100Key));
                }
            }
        }
예제 #3
0
    public void Start(OsuBeatmap beatmap)
    {
        Ac__DisplayClass18_0 ac__DisplayClass18_ = default(Ac__DisplayClass18_0);

        ac__DisplayClass18_.A4__this = this;
        ac__DisplayClass18_.beatmap  = beatmap;
        this.beatmap                     = ac__DisplayClass18_.beatmap;
        enabled                          = true;
        ac__DisplayClass18_.key1         = (VirtualKeyCode)osu.BindingManager.GetKeyCode(Bindings.OsuLeft);
        ac__DisplayClass18_.key2         = (VirtualKeyCode)osu.BindingManager.GetKeyCode(Bindings.OsuRight);
        currentKeyPressed                = ac__DisplayClass18_.key2;
        ac__DisplayClass18_.beatmapSpeed = (osu.Player.HitObjectManager.CurrentMods.HasFlag(Mods.DoubleTime) ? 1.5f : (osu.Player.HitObjectManager.CurrentMods.HasFlag(Mods.HalfTime) ? 0.75f : 1f));
        int num  = osu.HitWindow50(ac__DisplayClass18_.beatmap.OverallDifficulty);
        int num2 = osu.HitWindow50(ac__DisplayClass18_.beatmap.OverallDifficulty);
        int num3 = osu.HitWindow100(ac__DisplayClass18_.beatmap.OverallDifficulty);
        int num4 = osu.HitWindow300(ac__DisplayClass18_.beatmap.OverallDifficulty);

        ac__DisplayClass18_.hitObjectRadius = osu.HitObjectRadius(ac__DisplayClass18_.beatmap.CircleSize);
        ac__DisplayClass18_.alreadyHit      = false;
        bool flag = false;

        ac__DisplayClass18_.rand             = new Random();
        ac__DisplayClass18_.randomOffset     = ac__DisplayClass18_.rand.Next(-offset, offset);
        ac__DisplayClass18_.randomHoldTime   = ac__DisplayClass18_.rand.Next((int)(((float)holdTime - 5f) * ac__DisplayClass18_.beatmapSpeed), (int)(((float)holdTime + 5f) * ac__DisplayClass18_.beatmapSpeed));
        ac__DisplayClass18_.lastTimeHit      = 0;
        ac__DisplayClass18_.index            = osu.Player.HitObjectManager.CurrentHitObjectIndex;
        ac__DisplayClass18_.currentHitObject = ac__DisplayClass18_.beatmap.HitObjects[ac__DisplayClass18_.index];
        AStartg__releaseBothKeys18_2(ref ac__DisplayClass18_);
        Ac__DisplayClass18_1 ac__DisplayClass18_2 = default(Ac__DisplayClass18_1);

        while (osu.CanPlay && ac__DisplayClass18_.index < ac__DisplayClass18_.beatmap.HitObjects.Count && enabled)
        {
            TimingHelper.Delay(1u);
            if (osu.IsPaused)
            {
                Thread.Sleep(5);
                continue;
            }
            ac__DisplayClass18_2.currentTime = osu.CurrentTime;
            if (ac__DisplayClass18_2.currentTime >= ac__DisplayClass18_.currentHitObject.StartTime - num)
            {
                ac__DisplayClass18_.hitObjectPosition = ((ac__DisplayClass18_.currentHitObject is OsuSlider) ? (ac__DisplayClass18_.currentHitObject as OsuSlider).PositionAtTime(osu.CurrentTime) : ac__DisplayClass18_.currentHitObject.Position);
                if (!ac__DisplayClass18_.alreadyHit)
                {
                    if (AStartg__isMouseOnNote18_1(ref ac__DisplayClass18_))
                    {
                        if (ac__DisplayClass18_2.currentTime >= ac__DisplayClass18_.currentHitObject.StartTime + ac__DisplayClass18_.randomOffset)
                        {
                            flag = false;
                            AStartg__pressKey18_4(ref ac__DisplayClass18_, ref ac__DisplayClass18_2);
                        }
                    }
                    else if (ac__DisplayClass18_2.currentTime >= ac__DisplayClass18_.currentHitObject.StartTime + num2)
                    {
                        flag = true;
                        AStartg__pressKey18_4(ref ac__DisplayClass18_, ref ac__DisplayClass18_2);
                    }
                }
            }
            if (!flag & ac__DisplayClass18_.alreadyHit)
            {
                if (ac__DisplayClass18_2.currentTime >= ac__DisplayClass18_.currentHitObject.EndTime + ac__DisplayClass18_.randomOffset + ac__DisplayClass18_.randomHoldTime)
                {
                    AStartg__releaseKey18_5(ref ac__DisplayClass18_);
                    AStartg__getNextObject18_3(ref ac__DisplayClass18_);
                }
            }
            else if (ac__DisplayClass18_2.currentTime >= ac__DisplayClass18_.currentHitObject.EndTime + num2 + ac__DisplayClass18_.randomHoldTime)
            {
                AStartg__releaseKey18_5(ref ac__DisplayClass18_);
                AStartg__getNextObject18_3(ref ac__DisplayClass18_);
            }
            while (osu.CanPlay && ac__DisplayClass18_.index >= ac__DisplayClass18_.beatmap.HitObjects.Count && enabled)
            {
                Thread.Sleep(5);
            }
        }
    }
예제 #4
0
        public void Start()
        {
            shouldStop     = false;
            currentBeatmap = postProcessBeatmap(osuManager.Player.Beatmap);

            hitWindow50  = osuManager.HitWindow50(currentBeatmap.DifficultySection.OverallDifficulty);
            hitWindow100 = osuManager.HitWindow100(currentBeatmap.DifficultySection.OverallDifficulty);
            hitWindow300 = osuManager.HitWindow300(currentBeatmap.DifficultySection.OverallDifficulty);

            float audioRate = (osuManager.CurrentMods.HasFlag(Mods.DoubleTime) || osuManager.CurrentMods.HasFlag(Mods.Nightcore)) ? 1.5f : osuManager.CurrentMods.HasFlag(Mods.HalfTime) ? 0.75f : 1f;
            float maxBPM    = configManager.MaxSingletapBPM / (audioRate / 2);

            int            index, lastTime, hitTime = 0;
            bool           isHit, shouldStartAlternating, shouldAlternate;
            VirtualKeyCode currentKey;
            HitObject      currentHitObject;

            (int StartOffset, int HoldTime)currentHitTimings;

            reset();

            while (osuManager.CanPlay && index < currentBeatmap.HitObjects.Count && !shouldStop)
            {
                Thread.Sleep(1);

                if (configManager.EnableTimewarp)
                {
                    timewarp.Update(configManager.TimewarpRate, audioRate);
                }

                if (osuManager.IsPaused)
                {
                    if (isHit)
                    {
                        isHit = false;
                        releaseAllKeys();
                    }

                    continue;
                }

                if (lastTime > osuManager.CurrentTime)
                {
                    reset(true);
                    releaseAllKeys();
                    continue;
                }
                else
                {
                    lastTime = osuManager.CurrentTime;
                }

                int currentTime = osuManager.CurrentTime + configManager.AudioOffset;
                if (currentTime >= currentHitObject.StartTime - hitWindow50)
                {
                    if (!isHit)
                    {
                        var hitScanResult = getHitScanResult(index);
                        switch (hitScanResult)
                        {
                        case HitScanResult.CanHit when currentTime >= currentHitObject.StartTime + currentHitTimings.StartOffset:
                        case HitScanResult.ShouldHit:
                        {
                            isHit   = true;
                            hitTime = currentTime;

                            switch (configManager.PlayStyle)
                            {
                            case PlayStyles.MouseOnly when currentKey == configManager.PrimaryKey:
                                inputSimulator.Mouse.LeftButtonDown();
                                break;

                            case PlayStyles.MouseOnly:
                                inputSimulator.Mouse.RightButtonDown();
                                break;

                            case PlayStyles.TapX when !shouldAlternate && !shouldStartAlternating:
                                inputSimulator.Mouse.LeftButtonDown();
                                currentKey = configManager.PrimaryKey;
                                break;

                            default:
                                inputSimulator.Keyboard.KeyDown(currentKey);
                                break;
                            }
                        }
                        break;

                        case HitScanResult.MoveToNextObject:
                            moveToNextObject();
                            break;
                        }
                    }
                    else if (currentTime >= (currentHitObject is HitCircle ? hitTime : currentHitObject.EndTime) + currentHitTimings.HoldTime)
                    {
                        moveToNextObject();

                        if (currentHitObject is Spinner && currentHitObject.StartTime - currentBeatmap.HitObjects[index - 1].EndTime <= configManager.HoldBeforeSpinnerTime)
                        {
                            continue;
                        }

                        isHit = false;
                        releaseAllKeys();
                    }
                }
            }

            releaseAllKeys();

            if (configManager.EnableTimewarp)
            {
                timewarp.Reset();
            }

            while (osuManager.CanPlay && index >= currentBeatmap.HitObjects.Count && !shouldStop)
            {
                Thread.Sleep(5);
            }

            void reset(bool retry = false)
            {
                index            = retry ? 0 : closestHitObjectIndex;
                isHit            = false;
                currentKey       = configManager.PrimaryKey;
                currentHitObject = currentBeatmap.HitObjects[index];
                updateAlternate();
                currentHitTimings = randomizeHitObjectTimings(index, shouldAlternate, false);
                lastTime          = int.MinValue;

                if (configManager.EnableTimewarp)
                {
                    timewarp.Refresh();
                }
            }

            void updateAlternate()
            {
                var lastHitObject = index > 0 ? currentBeatmap.HitObjects[index - 1] : null;
                var nextHitObject = index + 1 < currentBeatmap.HitObjects.Count ? currentBeatmap.HitObjects[index + 1] : null;

                shouldStartAlternating = nextHitObject != null ? 60000 / (nextHitObject.StartTime - currentHitObject.EndTime) >= maxBPM : false;
                shouldAlternate        = lastHitObject != null ? 60000 / (currentHitObject.StartTime - lastHitObject.EndTime) >= maxBPM : false;
                if (shouldAlternate || configManager.PlayStyle == PlayStyles.Alternate)
                {
                    currentKey = (currentKey == configManager.PrimaryKey) ? configManager.SecondaryKey : configManager.PrimaryKey;
                }
                else
                {
                    currentKey = configManager.PrimaryKey;
                }
            }

            void moveToNextObject()
            {
                index++;
                if (index < currentBeatmap.HitObjects.Count)
                {
                    currentHitObject = currentBeatmap.HitObjects[index];

                    updateAlternate();
                    currentHitTimings = randomizeHitObjectTimings(index, shouldAlternate, inputSimulator.InputDeviceState.IsKeyDown(configManager.HitWindow100Key));
                }
            }
        }