mirror of
https://github.com/ppy/osu
synced 2024-12-13 02:17:32 +00:00
Use IGameplayClock
to ensure our clock source is correct
This commit is contained in:
parent
0e86102681
commit
04dad6c6e8
@ -101,7 +101,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
|
|
||||||
AddStep("Add trigger source", () => Player.HUDOverlay.Add(sampleTriggerSource = new TestGameplaySampleTriggerSource(Player.DrawableRuleset.Playfield.HitObjectContainer)));
|
AddStep("Add trigger source", () => Player.GameplayClockContainer.Add(sampleTriggerSource = new TestGameplaySampleTriggerSource(Player.DrawableRuleset.Playfield.HitObjectContainer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
@ -29,6 +31,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
private readonly Container<SkinnableSound> hitSounds;
|
private readonly Container<SkinnableSound> hitSounds;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IGameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
public GameplaySampleTriggerSource(HitObjectContainer hitObjectContainer)
|
public GameplaySampleTriggerSource(HitObjectContainer hitObjectContainer)
|
||||||
{
|
{
|
||||||
this.hitObjectContainer = hitObjectContainer;
|
this.hitObjectContainer = hitObjectContainer;
|
||||||
@ -104,11 +109,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
// Else we want the earliest valid nested.
|
// Else we want the earliest valid nested.
|
||||||
// In cases of nested objects, they will always have earlier sample data than their parent object.
|
// In cases of nested objects, they will always have earlier sample data than their parent object.
|
||||||
return getAllNested(mostValidObject.HitObject).OrderBy(h => h.StartTime).FirstOrDefault(h => h.StartTime > Time.Current) ?? mostValidObject.HitObject;
|
return getAllNested(mostValidObject.HitObject).OrderBy(h => h.StartTime).FirstOrDefault(h => h.StartTime > gameplayClock.CurrentTime) ?? mostValidObject.HitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isAlreadyHit(HitObjectLifetimeEntry h) => h.Result?.HasResult == true;
|
private bool isAlreadyHit(HitObjectLifetimeEntry h) => h.Result?.HasResult == true;
|
||||||
private bool isCloseEnoughToCurrentTime(HitObjectLifetimeEntry h) => Time.Current >= h.HitObject.StartTime - h.HitObject.HitWindows.WindowFor(HitResult.Miss) * 2;
|
private bool isCloseEnoughToCurrentTime(HitObjectLifetimeEntry h) => gameplayClock.CurrentTime >= h.HitObject.StartTime - h.HitObject.HitWindows.WindowFor(HitResult.Miss) * 2;
|
||||||
|
|
||||||
private IEnumerable<HitObject> getAllNested(HitObject hitObject)
|
private IEnumerable<HitObject> getAllNested(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user