2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-07-06 16:38:58 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-11-20 19:08:05 +08:00
|
|
|
using System.Collections.Generic;
|
2019-09-02 17:31:33 +08:00
|
|
|
using System.Diagnostics;
|
2020-11-20 19:08:05 +08:00
|
|
|
using osu.Framework.Threading;
|
2020-01-09 12:43:44 +08:00
|
|
|
using osu.Framework.Utils;
|
2020-11-20 19:08:05 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2019-07-29 16:05:13 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-07-06 16:38:58 +08:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Tests
|
|
|
|
{
|
2019-05-15 03:37:25 +08:00
|
|
|
public partial class TestSceneShaking : TestSceneHitCircle
|
2018-07-06 16:38:58 +08:00
|
|
|
{
|
2020-11-20 19:08:05 +08:00
|
|
|
private readonly List<ScheduledDelegate> scheduledTasks = new List<ScheduledDelegate>();
|
|
|
|
|
|
|
|
protected override IBeatmap CreateBeatmapForSkinProvider()
|
|
|
|
{
|
|
|
|
// best way to run cleanup before a new step is run
|
|
|
|
foreach (var task in scheduledTasks)
|
|
|
|
task.Cancel();
|
|
|
|
|
|
|
|
scheduledTasks.Clear();
|
|
|
|
|
|
|
|
return base.CreateBeatmapForSkinProvider();
|
|
|
|
}
|
|
|
|
|
2021-06-17 14:06:56 +08:00
|
|
|
protected override TestDrawableHitCircle CreateDrawableHitCircle(HitCircle circle, bool auto, double hitOffset = 0)
|
2018-07-06 16:38:58 +08:00
|
|
|
{
|
2021-06-17 14:06:56 +08:00
|
|
|
var drawableHitObject = base.CreateDrawableHitCircle(circle, auto, hitOffset);
|
2018-07-06 16:38:58 +08:00
|
|
|
|
2019-09-02 17:31:33 +08:00
|
|
|
Debug.Assert(drawableHitObject.HitObject.HitWindows != null);
|
|
|
|
|
2019-09-06 14:24:00 +08:00
|
|
|
double delay = drawableHitObject.HitObject.StartTime - (drawableHitObject.HitObject.HitWindows.WindowFor(HitResult.Miss) + RNG.Next(0, 300)) - Time.Current;
|
2020-11-20 19:08:05 +08:00
|
|
|
scheduledTasks.Add(Scheduler.AddDelayed(() => drawableHitObject.TriggerJudgement(), delay));
|
2019-07-29 16:05:13 +08:00
|
|
|
|
|
|
|
return drawableHitObject;
|
2018-07-06 16:38:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|