Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitRe

DrawableHitObject? blockingObject = null;

foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
foreach (var obj in enumerateTopLevelAliveObjectsUpTo(hitObject.HitObject.StartTime))
{
if (hitObjectCanBlockFutureHits(obj))
blockingObject = obj;
Expand Down Expand Up @@ -60,7 +60,7 @@ public void HandleHit(DrawableHitObject hitObject)
throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!");

// Miss all hitobjects prior to the hit one.
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
foreach (var obj in enumerateTopLevelAliveObjectsUpTo(hitObject.HitObject.StartTime))
{
if (obj.Judged)
continue;
Expand All @@ -77,22 +77,14 @@ public void HandleHit(DrawableHitObject hitObject)
private static bool hitObjectCanBlockFutureHits(DrawableHitObject hitObject)
=> hitObject is DrawableHitCircle;

private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
private IEnumerable<DrawableHitObject> enumerateTopLevelAliveObjectsUpTo(double targetTime)
{
foreach (var obj in HitObjectContainer!.AliveObjects)
{
if (obj.HitObject.StartTime >= targetTime)
yield break;

yield return obj;

foreach (var nestedObj in obj.NestedHitObjects)
{
if (nestedObj.HitObject.StartTime >= targetTime)
break;

yield return nestedObj;
}
}
}
}
Expand Down
23 changes: 21 additions & 2 deletions osu.Game/Rulesets/UI/GameplaySampleTriggerSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ protected override void Update()
// In the case there are no non-judged objects, the last hit object should be used instead.
if (candidate == null)
{
mostValidObject = hitObjectContainer.Entries.LastOrDefault();
var (_, lastEntry) = getEntryBounds();
mostValidObject = lastEntry;
}
else
{
Expand All @@ -136,7 +137,8 @@ protected override void Update()
}
else
{
mostValidObject ??= hitObjectContainer.Entries.FirstOrDefault();
var (firstEntry, _) = getEntryBounds();
mostValidObject ??= firstEntry;
}
}
}
Expand Down Expand Up @@ -177,6 +179,23 @@ protected override void Update()
return best ?? mostValidObject.HitObject;
}

private (HitObjectLifetimeEntry? first, HitObjectLifetimeEntry? last) getEntryBounds()
{
HitObjectLifetimeEntry? first = null;
HitObjectLifetimeEntry? last = null;

foreach (var entry in hitObjectContainer.Entries)
{
if (first == null || entry.HitObject.StartTime < first.HitObject.StartTime)
first = entry;

if (last == null || entry.HitObject.StartTime > last.HitObject.StartTime)
last = entry;
}

return (first, last);
}

private bool isAlreadyHit(HitObjectLifetimeEntry h) => h.AllJudged;
private bool isCloseEnoughToCurrentTime(HitObject h) => getReferenceTime() >= h.StartTime - h.HitWindows.WindowFor(HitResult.Miss) * 2;

Expand Down
Loading