2019-08-20 18:17:27 +00: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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2022-06-06 21:29:53 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
2019-08-20 18:17:27 +00:00
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|
|
|
{
|
|
|
|
public partial class DrawableSpinnerTick : DrawableOsuHitObject
|
|
|
|
{
|
|
|
|
public override bool DisplayResult => false;
|
|
|
|
|
2020-12-03 11:03:39 +00:00
|
|
|
protected DrawableSpinner DrawableSpinner => (DrawableSpinner)ParentHitObject;
|
|
|
|
|
2020-11-12 06:59:48 +00:00
|
|
|
public DrawableSpinnerTick()
|
2022-06-06 21:29:53 +00:00
|
|
|
: this(null)
|
2020-11-12 06:59:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-20 18:17:27 +00:00
|
|
|
public DrawableSpinnerTick(SpinnerTick spinnerTick)
|
|
|
|
: base(spinnerTick)
|
|
|
|
{
|
2022-06-06 21:29:53 +00:00
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2019-08-20 18:17:27 +00:00
|
|
|
}
|
|
|
|
|
Fix spinner ticks not playing samples correctly sometimes
Noticed this during work on https://github.com/ppy/osu/pull/25185.
In some circumstances, it seemed that spinner bonus ticks (and mostly
them specifically) would not always play with the correct volume.
Hours of debugging later pointed at a trace at
`DrawableAudioWrapper.refreshLayoutFromParent()` not firing sometimes.
Initially I thought it to be some sort of framework bug, but after
preparing a diff and running final checks, I noticed that sometimes
the sample was being played *by a `PoolableSkinnableSample` that wasn't
loaded*. And determining why *that* is the case turned out with this
diff.
As it happens, spinner ticks get assigned a start time proportionally,
i.e. the 1st of 10 ticks is placed at 10% of the duration, the 2nd
at 20%, and so on. The start time generally shouldn't matter,
because the spinner is manually judging the ticks. *However*, the ticks
*still* receive a lifetime start / end in the same way normal objects
do, which means that in some cases they can *not be alive* when they're
hit, which means that the `DrawableAudioWrapper` flow *hasn't had
a chance to run*, and rightly so.
To fix, ensure that all spinner ticks are alive throughout the entirety
of the spinner's duration.
2023-10-23 19:26:25 +00:00
|
|
|
protected override void OnApply()
|
|
|
|
{
|
|
|
|
base.OnApply();
|
|
|
|
|
|
|
|
// the tick can be theoretically judged at any point in the spinner's duration,
|
|
|
|
// so it must be alive throughout the spinner's entire lifetime.
|
|
|
|
// this mostly matters for correct sample playback.
|
|
|
|
LifetimeStart = DrawableSpinner.HitObject.StartTime;
|
|
|
|
}
|
|
|
|
|
2019-12-25 02:34:12 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Apply a judgement result.
|
|
|
|
/// </summary>
|
2020-07-21 10:48:44 +00:00
|
|
|
/// <param name="hit">Whether this tick was reached.</param>
|
2020-09-29 05:35:43 +00:00
|
|
|
internal void TriggerResult(bool hit) => ApplyResult(r => r.Type = hit ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2019-08-20 18:17:27 +00:00
|
|
|
}
|
|
|
|
}
|